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
That response you are getting is what you get from /signalk
So the proxy is passing that on.
And what value should I put to proxy_pass?
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
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
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
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
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
Nothing related to react here
On my phone, i’ll share my nginx conf later
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.
- http: pass everything, from the root
- separate, specific websocket proxypasses for signalk and node-RED admin