We are using Nginx to host our Meteor app. I would like to have a separate Meteor instance host the marketing pages so that initial page load is much faster. When I am doing this, 2 errors happen.
- The images don’t load properly
- The websocket connection gets broken
current sites-available/app
# this section is needed to proxy web-socket connections
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# HTTP
server {
listen 80 default;
server_name stage.agolo.com;
location = /favicon.ico {
root /home/will/portal/programs/web.browser/app;
access_log off;
}
location ~* "^/[a-z0-9]{40}\.(css|js)$" {
root /home/will/portal/programs/web.browser;
gzip_static on;
access_log off;
}
location ~* \.(eot|ttf|woff)$ {
root /home/will/portal/programs/web.browser;
access_log off;
add_header Access-Control-Allow-Origin *;
add_header Vary Origin;
add_header Pragma public;
add_header Cache-Control "public";
expires max;
}
location ~ "^/packages" {
root /home/will/portal/programs/web.browser;
access_log off;
}
location / {
proxy_pass http://127.0.0.1:8080;
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
proxy_set_header Host $host;
}
location /splash {
rewrite ^ http://stageportal.agolo.com$request_uri? permanent;
}
}
Then sites-available/marketing
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80; # if this is not a default server, remove "default_server"
server_name stageportal.agolo.com;
location = /favicon.ico {
root /home/will/marketing/bundle/programs/web.browser/app;
access_log off;
}
location ~* "^/[a-z0-9]{40}\.(css|js)$" {
root /home/will/marketing/bundle/programs/web.browser;
gzip_static on;
access_log off;
}
location ~* \.(eot|ttf|woff)$ {
root /home/will/marketing/bundle/programs/web.browser;
access_log off;
add_header Access-Control-Allow-Origin *;
add_header Vary Origin;
add_header Pragma public;
add_header Cache-Control "public";
expires max;
}
location ~ "^/packages" {
root /home/will/marketing/bundle/programs/web.browser;
access_log off;
}
location /splash {
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
proxy_set_header Host $host;
}
}