Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy-Gate docker container style.css 404 not found when running behind nginx reverse proxy in a subfolder / subpath #37

Closed
etescartz opened this issue Oct 14, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@etescartz
Copy link

etescartz commented Oct 14, 2024

Easy-Gate looks like something I could use and wanted to give it a try. I am using a nginx reverse proxy and followed the mentioned confiuration:

[...]
"behind_proxy": true,
[...]

I first noticed that the page style was only showing basic html content after starting the easygate containter using the lastest docker image.

I also use this in my easy-gate nginx config file.

location / {
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_pass http://easy-gate:8080;
}
[...]

I initially thought there was a file location or path I missed and started going through the container's file system looking for a style.css file and didn't find any.

Then I started looking at the Dockerfile and thought I would try to build an image locally but ran into GO proxy authentication issues with some of the go dependencies ( for github.com/klauspost/compress the docker build command said access denied which after a short web search I found out is related to the specific go proxy being used)

This opened a whole new can of worms for me since I don't have a go environment set up on my machine and I'm not looking to pursue that.

Please let me know if I'm missing some important easy-gate configuration detail.
At first glance I would think that the style.css file is not built into the easy-gate docker image. I'm not a go developer and I may be mistaken, so if there's any way that you could make these static files available in the docker image I would be grateful.

@r7wx
Copy link
Owner

r7wx commented Oct 14, 2024

Hello,

Im not quite sure if you are trying to provide a custom css file or you are referring to the standard style.css file. The standard one is embedded in easy-gate binary and should be available by default even inside the Docker image. The default interface should be similar to the screenshot you can see in the readme (the first white one). Can you check if you are trying to provide easy-gate with a custom css file by looking at the configuration for:

"theme": {
  "custom_css": "/path/to/custom.css"
}

If so, and you are not interested in using a custom css file you can simply remove this line from the configuration.

If you want to use a custom CSS file instead you need to make sure to specify the correct path (relative to the docker filesystem) inside the configuration file and use a docker volume to make the syte.css file available inside the container.

Something like this:

docker run -d --name=easy-gate \
  -p 8080:8080 \
  -v ./easy-gate.json:/configs/easy-gate.json \
  -v ./path/to/style.css:/configs/style.css \
  --restart unless-stopped \
  -e EASY_GATE_CONFIG_PATH=/configs/easy-gate.json \
  r7wx/easy-gate:latest

Let me know if this works for you

@etescartz
Copy link
Author

Thanks for writing back!

I just want the standard builtin style.css file.

I think I'm missing something in my nginx reverse proxy config.
I tried to force Nginx to forward all requests to the Go app, including static assets like this:

server {
    listen 443 ssl;

    server_name  nas.local;

    location /easy-gate/ {
        proxy_pass http://easy-gate:8080/;
        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 $scheme;
    }
}

But the Nginx logs still show that it's trying to load style.css, favicon.ico from the Nginx container, not from the easy-gate docker container:

10.0.0.124 - - [14/Oct/2024:17:29:20 +0000] "GET /easy-gate/ HTTP/1.1" 200 6870 "-"
2024/10/14 17:29:20 [error] 21#21: *1 open() "/usr/share/nginx/html/style.css" failed (2: No such file or directory), client: 10.0.0.124, server: _, request: "GET /style.css HTTP/1.1", host: "nas.local", referrer: "https://nas.local/easy-gate/"
10.0.0.124 - - [14/Oct/2024:17:29:20 +0000] "GET /style.css HTTP/1.1" 404 153 "https://nas.local/easy-gate/"

Just for reference, here is the content of my easy-gate.yml configuration file which I'm enforcing using -e EASY_GATE_CONFIG_PATH=/etc/easy-gate/easy-gate.yml

addr: 0.0.0.0:8080
use_tls: false
cert_file: ""
key_file: ""
behind_proxy: true
title: Easy Gate
theme:
  background: "#000000"
  foreground: "#FFFFFF"
groups:
  - name: internal
    subnet: 10.0.0.0/24
services:
  - name: Forgejo
    category: "Code"
    url: https://nas.local/forgejo/
    groups:
      - internal

This custom easy gate works because I can see it in the browser but like said, it's just basic html.

I'll keep trying looking for nginx config options that might fix this for me.

@etescartz
Copy link
Author

I managed to get Nginx to pass everything to the easy-gate docker container by specifically routing requests for the style.css, favicon.ico and roboto-regular.ttf files to easy-gate:8080

server {
    listen 443 ssl;

    server_name  nas.local;

    location /easy-gate/ {
        rewrite ^/easy-gate(/.*)$ $1 break;
        proxy_pass http://easy-gate:8080;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /style.css {
        proxy_pass http://easy-gate:8080/style.css;
    }
    location /favicon.ico {
        proxy_pass http://easy-gate:8080/favicon.ico;
    }
    location /roboto-regular.ttf {
        proxy_pass http://easy-gate:8080/roboto-regular.ttf;
    }

    }
}

Now I can see CSS:

image

Would it be possible to make easy-gate handle requests when running in a subfolder or subpath, behind a reverse proxy?

@etescartz etescartz changed the title Easy-Gate docker container style.css 404 not found when running behind nginx reverse proxy Easy-Gate docker container style.css 404 not found when running behind nginx reverse proxy in a subfolder Oct 14, 2024
@etescartz etescartz changed the title Easy-Gate docker container style.css 404 not found when running behind nginx reverse proxy in a subfolder Easy-Gate docker container style.css 404 not found when running behind nginx reverse proxy in a subfolder / subpath Oct 14, 2024
@r7wx
Copy link
Owner

r7wx commented Oct 14, 2024

I was about to write the same thing 😄
You are correct the problem is the subpath "easy-gate", I need to push a fix to be able to specify a root folder for the application.

@r7wx r7wx added the bug Something isn't working label Oct 14, 2024
@r7wx
Copy link
Owner

r7wx commented Oct 14, 2024

Issue should now be fixed on v2.0.2 (https://github.com/r7wx/easy-gate/releases/tag/2.0.2)
You can now change the root path by using the env variable EASY_GATE_ROOT_PATH.
In your case you should set this env variable to "easy-gate"

@etescartz
Copy link
Author

Works like a charm! Thanks for implementing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants