diced / zipline

A ShareX/file upload server that is easy to use, packed with features, and with an easy setup!
https://zipline.diced.sh/
MIT License
1.31k stars 128 forks source link

Apache reverse proxy #540

Closed mihha closed 6 months ago

mihha commented 6 months ago

What happened?

This is actually not a bug, but you don't have any other category

I am trying to run Zipline using docker compose, behind the Apache reverse proxy

I am asking here has anyone managed to do that?

My Apache server error log shows the following

[Fri Mar 01 14:32:23.218135 2024] [proxy_http:error] [pid 2326694:tid 139857980589632] (104)Connection reset by peer: [remote 86.32.117.110:6518] AH01102: error reading status line from remote server localhost:3300
[Fri Mar 01 14:32:23.753769 2024] [proxy_http:error] [pid 2326694:tid 139858039338560] (104)Connection reset by peer: [remote 86.32.117.110:6518] AH01102: error reading status line from remote server localhost:3300, referer: https://zipline.mihha-hosting.com/

No idea what to do with that. I have searched internet and tried all the suggestions I could find This is the part of my Apache virtual host configuration

ProxyPass / http://localhost:3300/
ProxyPassReverse / http://localhost:3300/

Version

latest (ghcr.io/diced/zipline or ghcr.io/diced/zipline:latest)

What browser(s) are you seeing the problem on?

Chromium-based (Chrome, Edge, Brave, Opera, mobile chrome/chromium based, etc)

Zipline Logs

2024-03-01 02:19:59,929 PM info  [datasource] using Local(./uploads) datasource
2024-03-01 02:20:00,016 PM info  [database::migrations] establishing database connection
2024-03-01 02:20:00,018 PM info  [database::migrations] ensuring database exists, if not creating database - may error if no permissions
2024-03-01 02:20:00,207 PM info  [database::migrations] exiting migrations engine - database is up to date
2024-03-01 02:20:02,226 PM info  [server] listening on 0.0.0.0:3300
2024-03-01 02:20:02,226 PM info  [server] started production zipline@3.7.9 server

Browser Logs

No response

Additional Info

No response

mihha commented 6 months ago

After a really long struggle with huge amount of test and failures, I have come up with the solution

Posting the solution that works for me, so others, who will have a need to use Apache as reverse proxy can use it

Protocols h2 http/1.1

ProxyPreserveHost On
ProxyPass / http://localhost:3300/ flushpackets=on
ProxyPassReverse / http://localhost:3300/

RequestHeader set X-Forwarded-For "%{REMOTE_ADDR}e"
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
RequestHeader set Host expr=%{HTTP_HOST}

Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
Header always set Access-Control-Expose-Headers "Content-Security-Policy, Location"
Header always set Access-Control-Max-Age "600"

ProxyErrorOverride Off

<Proxy *>
    allow from all
</Proxy>

This can probably be optimized further, but as a starting point, it works

diced commented 6 months ago

This is actually not a bug, but you don't have any other category

You can use discussions for that

I have never used apache or wanted to, but I'd assume you want your config to look similar to how the provided NGINX config is: https://zipline.diced.sh/docs/guides/nginx/nginx-no-ssl - just a quick glance at what you posted seems to do that.

I'll be closing this, if i feel like it ill prolly add this to the docs but idk