Signalk behind reverse proxy Nginx

Hello, I would like to use SignalK behind a Nginx reverse proxy, I do my tests locally. With http://localhost:3000 in my browser oK, I get the dashboard. However, when I go through Nginx with https://localhost/signalk with in the configuration file : location /signalk { proxy_pass http://localhost:3000; # Redirect to the Node.js application proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } I don't have the dashboard page, I have the json file: { "endpoints": { "v1": { "version": "2.7.2", "signalk-http": "http://localhost/signalk/v1/api/", "signalk-ws": "ws://localhost/signalk/v1/stream", "signalk-tcp": "tcp://localhost:8375" } }, "server": { "id": "signalk-server-node", "version": "2.7.2" } } Do you know the path to the static files so I can direct nginx, like: Configuration to serve static files (HTML, CSS, JS) location /static/ { root /var/www/signalk; # Path to static files try_files $uri $uri/ =404; } Thanks
9 Replies
Scott Bender
Scott Bender6d ago
That response you are getting is what you get from /signalk So the proxy is passing that on.
Lithops
Lithops6d ago
And what value should I put to proxy_pass?
Scott Bender
Scott Bender6d ago
I don’t know! I have never tried. I just tried and I get the same thing grafana works with the same config We need an nginx expert
Karl-Erik Gustafsson
I think you need to reserve some port and root of that for SK. I'm not aware of option of serving SK from a sub path
server {
listen <SOMEPORT> ssl http2 default_server;
listen [::]:<SOMEPORT> ssl http2 default_server;
include /config/nginx/proxy-confs/*.subfolder.conf;
include /config/nginx/ssl.conf;
client_max_body_size 0;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}
server {
listen <SOMEPORT> ssl http2 default_server;
listen [::]:<SOMEPORT> ssl http2 default_server;
include /config/nginx/proxy-confs/*.subfolder.conf;
include /config/nginx/ssl.conf;
client_max_body_size 0;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
}
}
For Grafana, there is option serving it under a sub path https://grafana.com/tutorials/run-grafana-behind-a-proxy/#alternative-for-serving-grafana-under-a-sub-path
Teppo Kurki
Teppo Kurki6d ago
What karl-erik said. @Lithops your configuration was just incorrect I think sk should work with a few proxypasses and does not need to occupy root, but the proxypasses need to map paths 1 to 1
Lithops
Lithops5d ago
Thanks for your feedback, I still don't have any results, I think my problem comes from REACT, which I don't know well. Here is my entire signalk.conf file server { listen 443 ssl; server_name localhost; # Or use your domain name ssl_certificate /etc/nginx/ssl/nginx-selfsigned.crt; ssl_certificate_key /etc/nginx/ssl/nginx-selfsigned.key; # Enable secure TLS protocols ssl_protocols TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES12 8-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384'; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; location /signalk { proxy_pass http://localhost:3000; # Redirects to Node.js application proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; #Log files for this application access_log /var/log/nginx/signalk_access.log; error_log /var/log/nginx/signalk_error.log; } #Default configuration to avoid using local directories location / { return 404; } } server { listen 80; server_name localhost; #Redirect HTTP requests to HTTPS return 301 https://$host$request_uri; } I'm still looking
Teppo Kurki
Teppo Kurki5d ago
Nothing related to react here On my phone, i’ll share my nginx conf later
Karl-Erik Gustafsson
As Teppo said, you have to map paths 1-to-1 or use root to map all paths. Now you are serving only /signalk location and root / return 404. This setup will not work.
Teppo Kurki
Teppo Kurki5d ago
server {
listen 80;
server_name your_hostname;
location / {
return 301 https://$host$request_uri;
}
}

server {
listen 443 ssl;
listen [::]:443;
server_name your_hostname;

ssl_certificate /etc/letsencrypt/live/your_hostname/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your_hostname/privkey.pem;

location / {
proxy_pass http://host.docker.internal:3000;
}

location /signalk/v1/stream {
proxy_pass http://host.docker.internal:3000/signalk/v1/stream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /plugins/signalk-node-red/redAdmin/comms {
proxy_pass http://host.docker.internal:3000/plugins/signalk-node-red/redAdmin/comms;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
listen 80;
server_name your_hostname;
location / {
return 301 https://$host$request_uri;
}
}

server {
listen 443 ssl;
listen [::]:443;
server_name your_hostname;

ssl_certificate /etc/letsencrypt/live/your_hostname/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your_hostname/privkey.pem;

location / {
proxy_pass http://host.docker.internal:3000;
}

location /signalk/v1/stream {
proxy_pass http://host.docker.internal:3000/signalk/v1/stream;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /plugins/signalk-node-red/redAdmin/comms {
proxy_pass http://host.docker.internal:3000/plugins/signalk-node-red/redAdmin/comms;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
- http: pass everything, from the root - separate, specific websocket proxypasses for signalk and node-RED admin
Want results from more Discord servers?
Add your server