Skip to content

Instantly share code, notes, and snippets.

@perezale
Forked from dimitardanailov/sample-nginx.conf
Created June 25, 2017 04:31
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 perezale/5dcc42712be20ec9118bc297066fcc04 to your computer and use it in GitHub Desktop.
Save perezale/5dcc42712be20ec9118bc297066fcc04 to your computer and use it in GitHub Desktop.
Configuration for Laravel 5 application and Nginx
server {
listen 80 default deferred;
server_name laravel-application.com;
# http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
access_log /var/www/laravel-app/access.log;
error_log /var/www/laravel-app/error.log;
root /var/www/laravel-app/public/;
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
}
# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
# https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-nginx-on-an-ubuntu-12-04-lts-vps
location ~ \.php$ {
try_files $uri /index.php =404;
# Each fastcgi application have different port
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
# CORS settings
# http://enable-cors.org/server_nginx.html
# http://10.10.0.64 - It's my front end application
add_header 'Access-Control-Allow-Origin' 'http://10.10.0.64';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT';
add_header 'Access-Control-Allow-Headers' 'Version,Accept,Accept-Encoding,Accept-Language,Connection,Coockie,Authorization,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment