docker-rickroll icon indicating copy to clipboard operation
docker-rickroll copied to clipboard

Only works on 8080

Open cadeon opened this issue 1 year ago • 3 comments

If I run this on any other port - I've been using 1987 since that's the song's release year - I get a 500 error.

Works:

rickroll: image: modem7/docker-rickroll container_name: Rickroll ports: - 8080:8080 environment: - TITLE="not-really-roll" # Changes the title of the webpage - PORT=8080

Does not work:

rickroll: image: modem7/docker-rickroll container_name: Rickroll ports: - 1987:1987 environment: - TITLE="not-really-roll" # Changes the title of the webpage - PORT=1987

I've tried digging into this myself and have stumbled a lot. nginx errors don't seem to make it to the docker logs (maybe because /var/log/nginx is -> /dev/stderr ? maybe error level setting in nginx.conf ? ) but I suspect it has to do with the proxy setup, or maybe it's due to the nginx.conf file including configs from /etc/nginx/conf.d, which has a default.conf file which may be overriding / messing with the primary nginx.conf settings.

I may be able to do some further troubleshooting (if I manage to get a docker build environment up)... If I figure it out I'll send a PR.

cadeon avatar Jul 31 '24 16:07 cadeon

Recommend removing https://github.com/modem7/docker-rickroll/blob/0b00e07864c747d95baadf70c940ee81278c7a7f/scripts/70-nginx.sh#L32

cadeon avatar Jul 31 '24 16:07 cadeon

Even after changing

    access_log    /var/log/nginx/access.log  main;
    include       /etc/nginx/conf.d/*.conf;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

to (needed for the healthcheck config)

    access_log    /var/log/nginx/access.log  main;
    include       /etc/nginx/conf.d/health-check.conf;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

The issue is still there.

I looked at netstat, and changing the port does indeed make nginx listen on that port, so that's working as intended:

docker exec -it Rickroll /bin/sh
/ $ netstat -tulpn | grep :1987
tcp        0      0 0.0.0.0:1987            0.0.0.0:*               LISTEN      1/nginx: master pro
/ $

The logs are redirected to console as is, but for some reason, it doesn't like changing ports.

This is the log entry I get:

192.168.0.100 - - [31/Jul/2024:23:34:26 +0000] "GET /favicon.ico HTTP/1.1" 500 579 "[http://192.168.50.254:1987/video.mp4"](http://192.168.50.254:1987/video.mp4%22) "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" "-"

It may be due to how I decided to reroute the container to the video rather than a page etc.

Only thing I've found so far is: https://github.com/nginxinc/docker-nginx-unprivileged/issues/164 but I don't think it relates to this issue.

I'm currently quite swamped at work, so it's unlikely I'll be able to put much effort into resolving this issue for the foreseeable, but if you figure it out, I'm happy to review, test and merge a PR.

modem7 avatar Jul 31 '24 23:07 modem7

It may be due to how I decided to reroute the container to the video rather than a page etc.

Yea I think this is it. Somehow nginx is trying to swap to 8080 for the video itself... not sure why.

I don't have an environment right now to try things but hopefully I will soon. If I can figure it out I'll share.

cadeon avatar Aug 01 '24 03:08 cadeon

Believe it or not I didn't forget about this. Comment on your open items at least once a year!

I've been able to reproduce the problem, it is still there. I can also agree that Nginx is listening on whatever PORT is specified, but something dies when the video tries to load. I haven't been able to work out what's causing that. I feel like it has to be in the html

However... my "production" environment has changed significantly, and now this is no longer a "blocker."

Maybe it needs something like so in the Dockerfile? Feels like a stretch...

Define a default port in the Dockerfile

ENV APP_PORT=8080 EXPOSE ${APP_PORT}

cadeon avatar Jul 08 '25 02:07 cadeon

So the expose instruction is really just that, it's more there for documentation than anything functional (unless the container is set to host networking).

We define the port in https://github.com/modem7/docker-rickroll/blob/master/scripts/70-nginx.sh#L5 and apply it in https://github.com/modem7/docker-rickroll/blob/master/scripts/70-nginx.sh#L121 so that the plan is to make it dynamic. If we define it in the dockerfile, it'd be immutable unless you rebuild it each time.

I'm wondering if it's because we're using https://github.com/nginx/docker-nginx-unprivileged rather than a privileged container, and they may have some funky scripts running that override things.

modem7 avatar Jul 08 '25 09:07 modem7

OK, this is odd. I wonder if something has been fixed upstream.

I've just tested with:

  rickroll:
    image: modem7/docker-rickroll
    # image: rickroll:test
    container_name: Rickroll
    ports:
      - 1987:1987
    networks:
      pihole:
    environment:
      - PORT=1987

And this seems to work as originally intended. Can you verify?

And if it's not working remotely, does it work locally? I found an interesting thing in Cloudflare that was stopping things remotely at times if so.

modem7 avatar Jul 08 '25 11:07 modem7

Closing for now. Please re-open/comment if you're still having issues.

modem7 avatar Aug 07 '25 08:08 modem7