Skip to content

Instantly share code, notes, and snippets.

@marcodejongh
Forked from dweldon/meteor-nginx
Last active September 19, 2021 16:21
Show Gist options
  • Save marcodejongh/fcd738afc45cb7611a03 to your computer and use it in GitHub Desktop.
Save marcodejongh/fcd738afc45cb7611a03 to your computer and use it in GitHub Desktop.
http {
proxy_cache_path /tmp/nginx/cache
levels=1:2
keys_zone=main:10m
max_size=1g inactive=1d;
proxy_temp_path /tmp/nginx/tmp;
server {
listen 80;
server_name app.example.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
set $cache_key $scheme$host$uri$is_args$args;
listen 443;
server_name app.example.com;
ssl on;
ssl_certificate /etc/nginx/ssl/ssl.crt;
ssl_certificate_key /etc/nginx/ssl/ssl.key;
location = /favicon.ico {
root /home/ubuntu/app/bundle/programs/client/app;
access_log off;
expires 1w;
}
location ~* "^/[a-z0-9]{40}\.(css|js)$" {
root /home/ubuntu/app/bundle/programs/client;
access_log off;
expires max;
}
location ~ "^/packages" {
root /home/ubuntu/app/bundle/programs/client;
access_log off;
}
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
location /static {
proxy_pass http://localhost:3000/static;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache main;
proxy_cache_key $cache_key;
proxy_cache_valid 1d; #time till cache goes stale
proxy_cache_use_stale error
timeout
invalid_header
http_500
http_502
http_504
http_404;
expires 365d;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/plain application/x-javascript text/xml text/css;
gzip_vary on;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment