Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
My nginx config for dynmap (on port 8123, that's the dynmap bound to localhost so no direct call possible)
server {
listen 80;
# I normally wouldn't disable the access log but here I see no problem with it
access_log off;
error_log /var/log/nginx/;
# custom error page when map isn't available
error_page 502 503 504 =503 /503_map.html;
location = /503_map.html {
root /home/www/com.geekya/current/public;
# serve statics
location ~ ^/(tiles|css|images|js)/ {
root /home/geekyamc/_main/plugins/dynmap/web;
expires 0;
add_header Cache-Control private;
# forward anything else to the dynmap webserver
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_read_timeout 6;
# That is my dynmap webserver which is only accessible via localhost or through nginx

This comment has been minimized.

Copy link

aaronlockhartdev commented Aug 9, 2019

I still cannot get the proxy forwarding to work. When I type in chat it says its from my nginx server's ip instead of the players. How did you deal with this problem?


This comment has been minimized.

Copy link
Owner Author

2called-chaos commented Aug 19, 2019

It's been a while and I can't remember if I had that problem. To clarify, players ingame chat and it shows on dynmap as from the server?

When I type in chat it says its from my nginx server's ip instead of the players

That is what the two headers X-Real-IP and X-Forwarded-For are usually there for. But it requires the application on the other side to actually care about these. For the application behind nginx the REMOTE_ADDR will always be nginx (or localhost rather).

And/or are you using the PHP component for chat? Never looked into it but it might just blindly accept REMOTE_ADDR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.