Skip to content
This repository has been archived by the owner on May 29, 2018. It is now read-only.

NGINX configuration guide for reverse proxy

Andrew Newell edited this page Apr 15, 2017 · 1 revision

Tested 4/14/2017 on Ubuntu 16.04 LTS

Disclaimer:

I'm not very experienced with nginx so if this configuration is wonky let me know.

  • This configuration assumes you want to mount Plex-Board in the subfolder /plexdashboard.

    In order to achieve this configuration your server_config.yml would need the settings:

    web_host: 0.0.0.0
    port: 3000
    use_reverse_proxy: true
    relative_root: /plexdashboard
    
  • Don't forget to run ./serverSetup.sh if you change your relative_root! If you don't run that script live updating will not work!

  • Keep in mind the instructions in server_config.yml, relative_root should not have a trailing slash.

  • The nginx default configuration file is at: /etc/nginx/sites-available/default

  • You will have to restart nginx once you make changes to your configuration files.

NGINX config without relative_root

upstream app {
    # Path to Puma sock file. Yes, "///" is correct. 
    # Swap out "/opt/Plex-Board" to be wherever you installed the app. 
    server unix:///opt/Plex-Board/tmp/sockets/puma.sock fail_timeout=0;
}

server {
    listen 80 default_server;
    server_name localhost;
    # Swap out "/opt/Plex-Board" to be wherever you installed the app. It should point to the "public" folder.
    root /opt/Plex-Board/public;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_pass http://app;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        
        proxy_http_version 1.1;
        chunked_transfer_encoding off;
        proxy_buffering off;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}

NGINX config with relative_root

upstream app {
    # Path to Puma sock file. Yes, "///" is correct. 
    # Swap out "/opt/Plex-Board" to be wherever you installed the app. 
    server unix:///opt/Plex-Board/tmp/sockets/puma.sock fail_timeout=0;
}

server {
    listen 80 default_server;
    server_name localhost;
    # Swap out "/opt/Plex-Board" to be wherever you installed the app. It should point to the "public" folder.
    root /opt/Plex-Board/public;

    try_files $uri/index.html $uri @app;

    # Set this to whatever "relative_root you are using", in this case we are using "/plexdashboard/"
    location /plexdashboard/ {
        alias /opt/Plex-Board/public/;
        try_files $uri @app;
    }

    location @app {
        proxy_pass http://app;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        
        proxy_http_version 1.1;
        chunked_transfer_encoding off;
        proxy_buffering off;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
}