nginx proxy location config help
Hello, I am using Docker to deploy headscale, headscale-ui, and nginx.
headscale-ui:
image: ghcr.io/gurucomputing/headscale-ui:latest
container_name: headscale-ui
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
ports:
- "<PORT>:80"
When using nginx for reverse proxy configuration, I came up with a question. Currently, my nginx configuration is https://network.mydomain.com/web To provide external access to the headscale-ui, It can working.
map $http_upgrade $connection_upgrade {
default keep-alive;
'websocket' upgrade;
'' close;
}
server{
listen 443 ssl;
listen [::]:443 ssl;
server_name network.mydomain.com;
location /web {
proxy_pass http://<IPADDR>:<PORT>;
proxy_redirect http:// https://;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
}
}
But when I want to use https://esc.mydomain.com/headscale-ui When providing external access to the headscale ui, it doesn't seem to work. I tried using nginx's sub_filter replacement /web, but it doesn't work either.
map $http_upgrade $connection_upgrade {
default keep-alive;
'websocket' upgrade;
'' close;
}
server{
listen 443 ssl;
listen [::]:443 ssl;
server_name esc.mydomain.com;
location /headscale-ui/ {
proxy_pass http://<IPADDR>:<PORT>/web/;
proxy_redirect http:// https://;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
}
}
How to configure reverse proxy for nginx https://esc.mydomain.com/headscale-ui Can be accessed normally.
Looking forward to your reply, my friend. Wishing you all the best.
Sorry, I'm only providing technical support for caddy reverse proxies, though other people are welcome to chime in if there is still an issue.
is there any reason you need to have "web" in proxy_pass http://<IPADDR>:<PORT>/web/;
if your first config worked, you might only need to change 2 lines:
server_name network.mydomain.com; location /web {
to server_name esc.mydomain.com; location /headscale-ui/ {
(or /headscale-ui withoud "/" at the end, don't remember)
closing due to no recent activity