Skip to content

Instantly share code, notes, and snippets.

@2called-chaos
Last active April 6, 2024 23:58
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2called-chaos/4eacb303b9491d1e374c to your computer and use it in GitHub Desktop.
Save 2called-chaos/4eacb303b9491d1e374c to your computer and use it in GitHub Desktop.
My nginx config for dynmap (on port 8123, that's the dynmap bound to localhost so no direct call possible)
server {
listen 80;
server_name map.geekya.com;
# I normally wouldn't disable the access log but here I see no problem with it
access_log off;
error_log /var/log/nginx/com.geekya.map.error.log;
# 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;
break;
}
# 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
proxy_pass http://127.0.0.1:8123;
break;
}
}
@bamiesking
Copy link

@2called-chaos

I would recommend you to not do this with subdirectories (it will just give you headaches).

Is there any reason for this other than preference?

@2called-chaos
Copy link
Author

@bamiesking

Has been a while with dynmap for me and it might just work with it in this case but many web applications don't like it do be in a subdirectory. You then have to start rewriting URLs and then you might have emails with wrong links or some other edge cases.

@Griefed
Copy link

Griefed commented May 22, 2021

Thank you for this. I've been smashing by head through my keyboard trying to get my nginx to work with a remote dynmap server. This helped a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment