TeamPiped / Piped-Docker

MIT License
39 stars 32 forks source link

Apache with `Docker-Compose Nginx AIO script` -- site issues. #11

Closed Myridium closed 2 years ago

Myridium commented 2 years ago

The instructions under the heading Docker-Compose Nginx AIO script at https://piped-docs.kavin.rocks/docs/self-hosting/ say that all we need to do is set the DNS A records, run the docker, and pass the web traffic from all three hostnames to the nginx instance in the docker container.

I've done all this. I've copied the same configuration I have for multiple other web applications on different domains, but I cannot get Piped working. I'm getting a generic Index of / page when I navigate to piped.$host.

Here's my Apache httpd config:

<VirtualHost *:80>
    ErrorLog     /var/log/httpd/piped.http.info-error_log
    CustomLog    /var/log/httpd/piped.http.info-access_log common
    ServerName   piped.$host
    Redirect permanent / https://piped.$host/
</VirtualHost>
<VirtualHost *:80>
    ErrorLog     /var/log/httpd/piped.http.info-error_log
    CustomLog    /var/log/httpd/piped.http.info-access_log common
    ServerName   pipedapi.$host
    Redirect permanent / https://pipedapi.$host/
</VirtualHost>
<VirtualHost *:80>
    ErrorLog     /var/log/httpd/piped.http.info-error_log
    CustomLog    /var/log/httpd/piped.http.info-access_log common
    ServerName   pipedproxy.$host
    Redirect permanent / https://pipedproxy.$host/
</VirtualHost>
<VirtualHost *:443>
    ServerName   piped.$host
    ServerName   pipedapi.$host
    ServerName   pipedproxy.$host

    SSLEngine on
    SSLCertificateFile "/etc/letsencrypt/live/$host/fullchain.pem"
    SSLCertificateKeyFile "/etc/letsencrypt/live/$host/privkey.pem"

    RewriteEngine On

    ProxyRequests     Off
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:8071/
    ProxyPassReverse / http://127.0.0.1:8071/
</VirtualHost>

And in the docker-compose file I have

nginx:
    image: nginx:mainline-alpine
    restart: unless-stopped
    ports:
        - "8071:80"

The output of docker-compose up doesn't print anything extra after

piped-backend   | Cleanup: Removed 0 old videos

even when accessing the page.

Output of docker ps:

CONTAINER ID   IMAGE                                COMMAND                  CREATED          STATUS                    PORTS                                                               NAMES
9159694d0413   nginx:mainline-alpine                "/docker-entrypoint.…"   52 seconds ago   Up 45 seconds             0.0.0.0:8071->80/tcp, :::8071->80/tcp                               nginx
10d08a5d0619   1337kavin/piped-frontend:latest      "ash -c 'sed -i s/pi…"   52 seconds ago   Up 47 seconds             80/tcp                                                              piped-frontend
8337cbe086ea   varnish:7.0-alpine                   "/usr/local/bin/dock…"   52 seconds ago   Up 47 seconds (healthy)   80/tcp, 8443/tcp                                                    varnish
0b7397f7a149   1337kavin/piped:latest               "/bin/sh -c 'java -s…"   52 seconds ago   Up 49 seconds             8080/tcp                                                            piped-backend
46e5b137583a   containrrr/watchtower                "/watchtower piped-f…"   52 seconds ago   Up 50 seconds             8080/tcp                                                            watchtower
4aabdf9cc485   1337kavin/ytproxy:latest             "/bin/sh -c ./http3-…"   52 seconds ago   Up 50 seconds                                                                                 ytproxy
1aa5a288744c   postgres:13-alpine                   "docker-entrypoint.s…"   52 seconds ago   Up 50 seconds             5432/tcp                                                            postgres

...confirming that the server is running and listening on port 8071 on the host.

Likewise, nmap tells me the port is open and listening:

[user@host Piped-Docker]$ nmap -p 8071 localhost
Starting Nmap 7.92 ( https://nmap.org ) at 2021-12-03 XX:XX XXXX
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00011s latency).
Other addresses for localhost (not scanned): ::1

PORT     STATE SERVICE
8071/tcp open  unknown

Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds

The hostname in the URL bar is definitely resolving to the right server. It's even rewriting http to https per the httpd config. But still it shows the generic Index of / page.

Is this a problem with Piped-Docker? Any ideas?

Myridium commented 2 years ago

I will note that by adding

Header add Host "piped.$host"
RequestHeader set Host "piped.$host"

I am now able to access pipedproxy.$host but registration doesn't work and the site seems a little broken...

FireMasterK commented 2 years ago

Is there any way for me to access your instance to see what may be wrong?

(You can email kavin@kavin.rocks incase you want to do this privately)

Myridium commented 2 years ago

@FireMasterK thank you for the offer, but I managed to partially solve it. Apache actually needs ServerAlias to specify additional ServerNames beyond the first one. I made that change.

Now I have just have those issues with the site not working properly; cannot register; no feed showing. I navigate to piped.$host and try to register an account. When I press the "Register" button, nothing happens on the webpage, and the docker log says:

piped-frontend  | 2021/12/04 XX:XX:XX [error] 9#9: *651 open() "/usr/share/nginx/html/register" failed (2: No such file or directory), client: XXX.XXX.XXX.XXX, server: localhost, request: "POST /register HTTP/1.1", host: "pipedfrontend", referrer: "https://piped.$host/"

I ran docker exec -t -i <container_id> /bin/sh to open a shell inside the running 1337kavin/piped-frontend:latest image, and then navigated to /usr/share/nginx/html. I listed the files in that directory:

/usr/share/nginx/html # ls -1
50x.html
css
favicon.ico
img
index.html
js
manifest.json
opensearch.xml
precache-manifest.43484a6c04dbdbba2ab012c8b84985a9.js
robots.txt
service-worker.js
workbox-v4.3.1
/usr/share/nginx/html # 

... and confirmed that there is indeed no file /usr/share/nginx/html/register in the container.

Is this a problem with the docker image?

FireMasterK commented 2 years ago

Is this a problem with the docker image?

No, it's not, other deployments don't have this issue.

Myridium commented 2 years ago

Okay well, the docker image does not contain /usr/share/nginx/html/register which the server tries to access.

FireMasterK commented 2 years ago

It's impossible to get a 404 thanks to this line, something else is definitely wrong!

https://github.com/TeamPiped/Piped/blob/master/docker/nginx.conf#L11

Myridium commented 2 years ago

It's impossible to get a 404 thanks to this line, something else is definitely wrong!

https://github.com/TeamPiped/Piped/blob/master/docker/nginx.conf#L11

I'm not getting a 404. The "Register" button appears to do nothing on the user end. On the backend, the docker log says that /usr/share/nginx/register is not found. I deleted all related docker containers and volumes, restarted with docker-compose up and attached once again to the docker container of piped-frontend. The file is indeed missing from the container.

Myridium commented 2 years ago

I built the piped image and it is missing the relevant files which are supposed to be copied from /app/dist to /usr/share/nginx/html. No login file and no register file or directory. Image appears to be broken. Also tried commit hash 0d676c1. Something is broken with this image.

FireMasterK commented 2 years ago

I'm sorry, but there's no way to help you (since you don't want to share your hostname, and I'm unaware of how apache works) with this as this is clearly a problem on your end.

You can verify this by running:

curl --head -H "Host: piped.kavin.rocks" 127.0.0.1:8080/register
curl --head -H "Host: pipedapi.kavin.rocks" 127.0.0.1:8080/register # Should return a 404, and should indicate varnish's presence

If you find anything that could indicate a problem on my end, let me know and I'll re-open this issue.