Skip to content

Instantly share code, notes, and snippets.

@kuonvu
Last active September 28, 2018 06:44
Show Gist options
  • Save kuonvu/7cd5cc3bbe9678d5a2acda816cf77bc8 to your computer and use it in GitHub Desktop.
Save kuonvu/7cd5cc3bbe9678d5a2acda816cf77bc8 to your computer and use it in GitHub Desktop.
Config Nginx - Laravel api
server {
listen 8002;
client_max_body_size 108M;
access_log /var/log/nginx/server_name.access.log;
error_log /var/log/nginx/server_name.error.log;
root /var/www/html/server_name/public;
index index.php;
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
location ~ \.php$ {
if ($request_method ~* "(GET|POST|PUT|DELETE)") {
add_header "Access-Control-Allow-Origin" * always;
}
# Preflighted requests
if ($request_method = OPTIONS ) {
add_header "Access-Control-Allow-Origin" * always;
add_header "Access-Control-Allow-Methods" "GET, POST, PUT, DELETE, OPTIONS, HEAD";
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept, Cache-Control";
return 200;
}
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/server_name.error.log";
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param HTTPS off;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
@kuonvu
Copy link
Author

kuonvu commented Sep 28, 2018

server_name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment