[Adminsysters] [SERVPUB] sharing reverse proxy troubleshooting solution

rebeccaaston rebeccaaston at proton.me
Sat Dec 16 16:28:34 CET 2023


Hi all,

We were having an issue with the reverse proxy on any requests where the uri had anything after the base (e.g. servpub.net/anythingelse), these requests weren't being passed on correctly by Jean reverse proxy to our other nginx servers on the raspberry pis. The issue was affecting a media wiki site (using php) and also was affecting the serving of all static files (e.g. images).

I did some analysis of the nginx logs on Jean and the pi, and Mara was able to check / confirm that the solution below works. So I'm sharing the original analysis and resource where the solution was found as it's maybe useful to have the solution and the strategy used for figuring out/confirming what the issue was.

Best,

Becky / In-grid

---

If you go to wiki2print.servpub.net, the request access log on Jean will show:

[15/Dec/2023:14:49:40 +0100] "GET / HTTP/1.1" 301 5

Request gets immediately passed to wiki2print pi:

10.10.12.2 - - [15/Dec/2023:13:49:40 +0000] "GET / HTTP/1.0" 301 0

The 301 is showing that the php is doing what is expected by redirecting to the “/index.php?title=Main_Page” location, we then see this immediately in Jean access log:

[15/Dec/2023:14:49:40 +0100] "GET /index.php?title=Main_Page HTTP/1.1" 404 188

That request gives the 404 so it does not get passed to wiki2print (no record in nginx error or access log on wiki2print).

So I thought that what was happening with the above requests resulting in a 404 was the reverse proxy on Jean not handling the “/index.php?title=Main_Page” request correctly, the same issue happening with the serving of static files. So based on that I found this forum post which indicates that try_files is the thing that was causing our issue.

https://serverfault.com/questions/780585/nginx-403-when-serving-static-files-reverse-proxy

Solution based on the forum post above:

location @proxy {

proxy_pass[http://10.10.12.4](http://10.10.12.4/);

}

location / {

#other proxy stuff already there

# First attempt to serve request as file, then

# as directory, then fall back to displaying a 404.

# try_files $uri $uri/ =404; # <-- this is the problem

# simply pass the uri to the proxy to be handled by the server on the pis

try_files $uri @proxy;

}

Sent with [Proton Mail](https://proton.me/) secure email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genderchangers.org/pipermail/adminsysters/attachments/20231216/02fb9044/attachment-0001.htm>


More information about the Adminsysters mailing list