Skip to content

Instantly share code, notes, and snippets.

@RafikFarhad
Last active February 14, 2019 20: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 RafikFarhad/ed55581c73fbf0b96523e5288f9ef2d3 to your computer and use it in GitHub Desktop.
Save RafikFarhad/ed55581c73fbf0b96523e5288f9ef2d3 to your computer and use it in GitHub Desktop.
A default NGINX Configuration file with cache support.
server {
server_name _;
listen 80;
#charset koi8-r;
access_log /var/log/nginx/host.access.log main;
root /var/www/laravel/public;
index index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# Socket.io block
location ~* \.io {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 2M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 2M;
access_log off;
add_header Cache-Control "public";
}
# dynamic data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment