Last active
March 14, 2018 23:41
-
-
Save stuudmuffin/e5b80a31633c34fbc13f0ddee63a3b94 to your computer and use it in GitHub Desktop.
Minecraft dynmap nginx proxy error pages. We port our dynmap plugin through a proxy so we can secure it with https, and enable it as a folder extension instead of a random port or a root folder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sites-enabled/ssl.conf or default.conf. Change and add your configuration accordingly | |
# | |
# With this nginx configuration, we can default to showing an error page if the proxy fails. Our setup is | |
# a little unique, in that our domain name (mc.ourdomain.com) forwards anything 404 related to a our main | |
# site for server information (www.ourdomain.com/servers/minecraft) the only reason to use the mc subdoamin | |
# is to join the server, and view the map (mc.ourdomain.com/map). This config might be simplified if we | |
# were redirecting all other traffic (ie, the location = for specific image files may not be needed) | |
# | |
server { | |
listen 443 ssl; | |
server_name mc.ourdomain.com; | |
root /var/www/html/mc.ourdomain.com; | |
index index.php index.html; | |
location ^~ /map/ { | |
# This error page actually exists in the /map/ folder | |
error_page 500 501 502 503 504 = /500.php; | |
proxy_pass http://192.168.1.250:8123/; | |
} | |
# Since everything is redirected by default, we need to specifically map files that will be used for the error page | |
location = /map/sad_creeper_S.png { | |
root /var/www/html/mc.ourdomain.com/; | |
} | |
location = /500.php { | |
# We have a default action for .php files, but when nginx serves error pages, it seems to be ignoring that location directive | |
# I'll update the gist if I figure out a better config | |
# "root" must be used here instead of "alias", despite what people might say online about how root should never be used... | |
root /var/www/html/mc.ourdomain.com/map/; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
} | |
# You don't have to redirect everything else like this. I've only included it for example since I mentioned this is our setup is working | |
location / { | |
return 301 http://www.ourdomain.com/servers/minecraft; | |
} | |
# Other configs go here | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment