-
-
Save 2called-chaos/4eacb303b9491d1e374c to your computer and use it in GitHub Desktop.
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; | |
} | |
} |
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
Whats about https? How to use it for Port 443?
Whats about https? How to use it for Port 443?
Well, same as with any other nginx config :)
I would recommend using certbot, this page here gets you started easily: https://certbot.eff.org/instructions
As reference also take a look at http://nginx.org/en/docs/http/configuring_https_servers.html
okay thank you. I got it.
I know this is a few months old but I'm hoping there's someone that might come across this that knows the answer I'm looking for.
I need more than one dynmap instance behind one Nginx reverse proxy. At the moment this config only allows for one instance but I would like to know if it's possible to do the following:
- One map on http://url.com/survival
- One map on http://url.com/creative
- Both instances are completely separate server instances but are within the same docker-compose file.
If anyone knows the solution, either reply here or if you have Discord if you could contact me on that preferably, Kyle#0420
EDIT: Thank you Ben on Discord for helping me out :)
The gist for my nginx.conf
file mentioned by Kyle above is here.
I would recommend you to not do this with subdirectories (it will just give you headaches). I would recommend subdomains. You can then proxy_pass to as many different ports/dynmap as you want, each with their own hostname/subdomain.
You can still either make a redirect for // to .domain.tld or iframe the maps on your main page. I did the latter with just a fixed iframe spanning the whole viewport, only downside in that case is that users can't easily copy deeplinks.
I would recommend you to not do this with subdirectories (it will just give you headaches). I would recommend subdomains.
@2called-chaos My setup doesn't allow that, nor do I want that. But I'll keep it in mind just in case I need it, but everything is working fine here and is easily expandable. Thanks.
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?
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.
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.
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?