Skip to content

Instantly share code, notes, and snippets.

@marcodejongh
Forked from dweldon/meteor-nginx
Last active September 19, 2021 16:21

Revisions

  1. marcodejongh revised this gist Aug 21, 2014. 2 changed files with 76 additions and 53 deletions.
    53 changes: 0 additions & 53 deletions meteor-nginx
    Original file line number Diff line number Diff line change
    @@ -1,53 +0,0 @@
    server {
    listen 80;
    server_name app.example.com;
    rewrite ^ https://$server_name$request_uri? permanent;
    }

    server {
    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;
    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;
    }
    }
    76 changes: 76 additions & 0 deletions meteor-nginx-static-cache
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,76 @@
    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;
    }
    }

    }
  2. marcodejongh revised this gist Aug 21, 2014. 1 changed file with 14 additions and 0 deletions.
    14 changes: 14 additions & 0 deletions meteor-nginx
    Original file line number Diff line number Diff line change
    @@ -36,4 +36,18 @@ server {
    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;
    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;
    }
    }
  3. @dweldon dweldon revised this gist Sep 20, 2013. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions meteor-nginx
    Original file line number Diff line number Diff line change
    @@ -3,21 +3,21 @@ server {
    server_name app.example.com;
    rewrite ^ https://$server_name$request_uri? permanent;
    }

    server {
    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;
  4. @dweldon dweldon revised this gist Sep 20, 2013. 1 changed file with 8 additions and 3 deletions.
    11 changes: 8 additions & 3 deletions meteor-nginx
    Original file line number Diff line number Diff line change
    @@ -13,17 +13,22 @@ server {
    ssl_certificate_key /etc/nginx/ssl/ssl.key;

    location = /favicon.ico {
    root /home/ubuntu/app/bundle/static;
    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/static_cacheable;
    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;
  5. @dweldon dweldon created this gist Aug 4, 2013.
    34 changes: 34 additions & 0 deletions meteor-nginx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    server {
    listen 80;
    server_name app.example.com;
    rewrite ^ https://$server_name$request_uri? permanent;
    }

    server {
    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/static;
    access_log off;
    expires 1w;
    }

    location ~* "^/[a-z0-9]{40}\.(css|js)$" {
    root /home/ubuntu/app/bundle/static_cacheable;
    access_log off;
    expires max;
    }

    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;
    }
    }