Skip to content

Instantly share code, notes, and snippets.

@joseconstela
Last active June 29, 2016 10:43
Show Gist options
  • Save joseconstela/99f3ec069c7ab30610d794e5e1396129 to your computer and use it in GitHub Desktop.
Save joseconstela/99f3ec069c7ab30610d794e5e1396129 to your computer and use it in GitHub Desktop.
Nging site configuration for Meteor applications, as shown at http://joseconstela.com/nginx-config-files-for-production-ready-meteorjs-apps/
server_tokens off; # for security-by-obscurity: stop displaying nginx version
# this section is needed to proxy web-socket connections
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 8080;
listen 443 ssl;
server_name app.myapplication.com;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_certificate /home/ubuntu/certs/crt;
ssl_certificate_key /home/ubuntu/certs/key;
if ($http_user_agent ~ "MSIE" ) {
return 303 https://browser-update.org/update.html;
}
location / {
proxy_pass http://127.0.0.1:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; # allow websockets
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr; # preserve client IP
# no cache
expires -1;
# cache static
# this setting allows the browser to cache the application in a way compatible with Meteor
# on every applicaiton update the name of CSS and JS file is different, so they can be cache infinitely (here: 30 days)
# the root path (/) MUST NOT be cached
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment