Skip to content

Instantly share code, notes, and snippets.

@successgo
Last active November 28, 2019 07:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save successgo/0008a6b9b13e31e0fb7fe51c1e522fa1 to your computer and use it in GitHub Desktop.
Save successgo/0008a6b9b13e31e0fb7fe51c1e522fa1 to your computer and use it in GitHub Desktop.
Example nginx.conf
server {
listen 80;
server_name example.local;
root /path/to/root;
index index.html index.php;
add_header "Access-Control-Allow-Origin" * always;
location / {
# preflight request
if ($request_method = OPTIONS) {
add_header "Access-Control-Allow-Origin" *;
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD, DELETE, PUT";
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header "Access-Control-Max-Age" 1728000;
add_header "Content-Type" "text/plain; charset=UTF-8"
add_header "Content-Length" 0;
return 204;
}
# handle request
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ ^/.*\.php {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param HTTPS off;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment