Skip to content

Instantly share code, notes, and snippets.

@jimmyislive
Last active January 3, 2018 17:45
Show Gist options
  • Select an option

  • Save jimmyislive/9709924 to your computer and use it in GitHub Desktop.

Select an option

Save jimmyislive/9709924 to your computer and use it in GitHub Desktop.
Single Page App components
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
##
# Basic Settings
##
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_names_hash_bucket_size 128;
# server_name_in_redirect off;
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
#Remember this setting for 365 days, HSTS
add_header Strict-Transport-Security max-age=31536000;
#prevent any page from being shown in an iframe
add_header X-Frame-Options DENY;
#for ie
add_header X-XSS-Protection 1:mode=block;
#prevent ie from mime-sniffing
add_header X-Content-Type-Options nosniff;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
#text/html is always compressed by default
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
#google recommendation for min length below which not to gzip
#default nginx value is 20
gzip_min_length 150;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl spdy;
#ssl on;
ssl_certificate /etc/ssl/packageindex.crt;
ssl_certificate_key /etc/ssl/packageindex.key;
server_name packageindex.com www.packageindex.com;
#let nginx serve all static media
location ~ ^/(images/|img/|javascript/|javascripts/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico) {
root /home/pindex/packageindex/web/public;
access_log off;
expires max;
}
location /status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location / {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_cache one;
proxy_cache_key sfs$request_uri$scheme;
#send to varnish
proxy_pass http://127.0.0.1:6081;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment