-
-
Save syntaxlexx/35065ad373bd93830c9e4b1fcf781ac0 to your computer and use it in GitHub Desktop.
nginx phpfpm + CORS configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream phpfpm { | |
server 127.0.0.1:9000; | |
} | |
server { | |
listen 80; | |
server_name _; | |
root /var/www/html; | |
index index.php; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ "\.php$" { | |
# requires http://wiki.nginx.org/HttpHeadersMoreModule to handle response codes that add_header ignores | |
more_set_headers "Access-Control-Allow-Origin: $http_origin"; | |
more_set_headers "Access-Control-Allow-Credentials: true"; | |
more_set_headers "Access-Control-Allow-Methods: GET, POST, DELETE, PUT, OPTIONS"; | |
more_set_headers "Access-Control-Allow-Headers: Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization"; | |
more_set_headers "Access-Control-Max-Age: 1728000"; | |
include fastcgi_params; | |
fastcgi_pass phpfpm; | |
fastcgi_index index.php; | |
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