Skip to content
Squirrely edited this page Jun 6, 2017 · 6 revisions

Reverse Proxying with Nginx

Meteor apps can easily be hosted behind an Nginx webserver by configuring a reverse proxy. You should be using an nginx version >= 1.4, for the best support of WebSockets.

Here is an example configuration that uses a custom port and url base:

server {

    # [...other configuration...]
  location ^~ /requests/ {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://127.0.0.1:3000/requests;
        # For keepalive sessions and WebSockets:
        proxy_http_version  1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # On every application update the name of the CSS and JS files are
        # different, so they can be cached indefinitely. However, the root path
        # **must not** be cached!
        if ($uri != '/requests/') {
            expires 30d;
        }
    }
}

Then you have to launch meteor with a custom ROOT_URL:

$ ROOT_URL=http://127.0.0.1:3030/requests meteor

or if you have plexrequests as a systemd service, add this line under [Service]

Environment=ROOT_URL=http://localhost:3000/requests

Voilà! You can now access Plex Requests at https://your.domain/plexrequests

You have secured your server with Let's Encrypt right? I recommend the lightweight letsencrypt.sh script.


Reference:

Clone this wiki locally