danbogen
By:
danbogen

Node-Red Nginx Reverse-Proxy location problem

October 24, 2017 121 views
Nginx Ubuntu 16.04

I followed the excellent tutorial on setting up Node-Red at
https://www.digitalocean.com/community/tutorials/how-to-connect-your-internet-of-things-with-node-red-on-ubuntu-16-04
It works when I access Node-Red directly from my domain, but I want to access Node-Red, not directly from my domain address (e.g. mysite.com), but from a page on my domain (e.g., mysite.com/node-red).

I am getting a "Cannot GET" error.

This /etc/nginx/sites-enabled/ code works:

server {
    listen 80;
    listen 443 ssl http2;
    server_name mysite.com www.mysite.com;
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers On;
    ssl_session_cache shared:SSL:128m;
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8;

     location / {
        if ($scheme = http) {
            return 301 https://$server_name$request_uri;
        }
        proxy_pass http://localhost:1880;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        }

location '/.well-known/acme-challenge' {
        root /var/www/html;
    }
}


This does not:

server {
    listen 80;
    listen 443 ssl http2;
    server_name mysite.com www.mysite.com;
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers On;
    ssl_session_cache shared:SSL:128m;
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8;

     location  /node-red  {
        if ($scheme = http) {
            return 301 https://$server_name$request_uri;
        }
        proxy_pass http://localhost:1880;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        }

location '/.well-known/acme-challenge' {
        root /var/www/html;
    }
}

I get this error on the webpage:

Cannot GET /node-red

I can't figure this out. Thanks,

Dan

Be the first one to answer this question.