headscale-ui icon indicating copy to clipboard operation
headscale-ui copied to clipboard

nginx proxy location config help

Open hraulein opened this issue 2 years ago • 2 comments

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.

hraulein avatar Dec 11 '23 06:12 hraulein

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.

routerino avatar Dec 29 '23 01:12 routerino

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)

ljubomirb avatar Feb 06 '24 14:02 ljubomirb

closing due to no recent activity

routerino avatar Apr 22 '24 10:04 routerino