alexjustesen / speedtest-tracker-docs

Docs for Speedtest Tracker.
https://docs.speedtest-tracker.dev/
15 stars 20 forks source link

Documentation nginx reverse proxy #3

Closed fana13 closed 1 year ago

fana13 commented 1 year ago

Could we have a documentation for nginx reverse proxy please ? I've tried to add the APP_URL like https://127.0.0.1/speedtest in .env and a configuration in my nginx.conf something like this

location /speedtest { proxy_pass https://127.0.0.1:3149/speedtest; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

But it doesn't work. Thanks.

alexjustesen commented 1 year ago

@fana13 sounds like a good idea especially to clear up how .env is treated for those not familiar with it's usage. I'm going to transfer this issue over to the docs repo.

Spazholio commented 1 year ago

Is there a BASE_URL environment variable or something similar needed to get this working behind an nginx reverse proxy?

alexjustesen commented 1 year ago

@Spazholio you'll want to use APP_URL

Spazholio commented 1 year ago

Ok, so I have the following in my docker-compose.yml:

  speedtest-tracker:
    container_name: speedtest-tracker
    ports:
      - '8180:80'
      - '8143:443'
    environment:
      - APP_URL=/speedtest-tracker
      - PUID=1000
      - PGID=1000
      - TZ=America/Detroit
    volumes:
      - /mnt/data/appdata/speedtest-tracker:/config
    image: ghcr.io/alexjustesen/speedtest-tracker:latest
    restart: always

And I have the following in my SWAG config:

## Version 2022/09/08

location /speedtest-tracker {
    return 301 $scheme://$host/speedtest-tracker/;
}

location ^~ /speedtest-tracker/ {
    # enable the next two lines for http auth
    #auth_basic "Restricted";
    #auth_basic_user_file /config/nginx/.htpasswd;

    # enable for ldap auth (requires ldap-server.conf in the server block)
    #include /config/nginx/ldap-location.conf;

    # enable for Authelia (requires authelia-server.conf in the server block)
    #include /config/nginx/authelia-location.conf;

    include /config/nginx/proxy.conf;
    include /config/nginx/resolver.conf;
    set $upstream_app speedtest-tracker;
    set $upstream_port 80;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

I then try to go to https://[MY-DOMAIN-NAME]/speedtest-tracker but it's not working. I get a 404. Which clearly obvious thing am I missing?

oregonpillow commented 1 month ago

A working swag example looks like this for me - assuming your container is called speedtest :

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name speedtest.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app speedtest;
        set $upstream_port 80;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

        proxy_set_header Range $http_range;
        proxy_set_header If-Range $http_if_range;
    }
}
Spazholio commented 4 weeks ago

Does this work if I'm using subdirectories instead of subdomains?

oregonpillow commented 4 weeks ago

Does this work if I'm using subdirectories instead of subdomains?

No sorry, only for subdomain. Sorry i failed to notice you wanted subfolder. My advice is, find a swag subfolder example config, which is very simple and doesn't add any fancy options. Adapting the emby.subfolder.sample for example might be a good place to start as I know this app has pretty simple Nginx settings.