I follow this, its very outdated but I got the gist of it.
https://github.com/webbukkit/dynmap/wiki/Setting-up-without-the-Internal-Web-Server
I setup a nginx server with http2 and https all working with the domain I wanted https://map.piratemc.com
I coped over the /web directory, updated my tiles & web to the correct directory, I chmodded the /standalone folder, I disabled the internal web-server and the chat features (I don't have PHP installed as I just want to use the map)
Here is my config http://pastebin.com/ZRSSdiLb
I don't see dynmap_world.json in the standalone folder at all, is this a permissions error? if so how do I fix it?
I previously had my map working fine using the internal web-server, but it needs to be using HTTPS so I can embed it.
Map location is https://map.piratemc.com
Off the bat, your dynmap config appears to be correct and proper.
What does your nginx config look like?
But anyway, this seems to be a permissions error,
What user is minecraft/spigot/bukkit running as? Is that the same one that owns /home/tom/public_html/? Does MC-user have permissions to read, write, and list to /home/tom/public_html/?
On my setup what I did was leave the standalone folder where it was and create a symlink so that my httpd could traverse and read, and so that I didn't have to do funky permissions with my MC user to write to the /var/www/folder.
Like this:
# ls -lah /var/www/html/map
lrwxrwxrwx 1 root root 45 Dec 7 07:23 /var/www/html/map -> /home/minecraft/minecraft/plugins/dynmap/web/
I created a request/issue to add a new wiki page for this specific setup, it might be worth it to give it a read.
https://github.com/webbukkit/dynmap/issues/2027
Also another note, you need PHP in order to have nginx serve the web & standalone files properly.
Give this a read in order to secure your setup, most nginx+php tutorials out there are bad and could open you to the possibility of exploitation.
https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/
Edit: PHP IS required for Dynmap no matter what. That's how it understands how to query the filestore and update the page properly
As jwshields says, missing PHP is the issue. I used this guide to get PHP set-up. You can skip the mysql parts if you don't need MySQL server on the server.
The PHP files are there, but the current setup doesn't let nginx know how to take care of .php files.
@SimonOrJ I read in the docs that the PHP was only needed to run the web-chat? thats why I disabled it so that I didn't need php!
Either way, I tried to install on Debian 8 and I get E: Unable to locate package php-fpm, Plus wouldn't this install PHP 7? Which after looking at the issues on this repo dousnt seem to be supported.
@jwshields Thanks for the info! Im not sure what user im running it as, as I run using mark2 wrapper, im assuming it uses my local user as thats the user im running it from! any way I can check?
I cant believe I didn't think of using a symlink, it took an hour to copy my 13GB of tiles... a symlink would have been instant! bah! Ill give this a try to see if its permissions before trying to figure out how to install PHP-fpm safely on debian 8.
php5-fpm is the package you need. It's the standard on most all web servers these days. And it's required to have the map work entirely. I'm unsure why that Wiki page states that but it's wholly untrue.
EDIT: I really dislike that wiki page, as I've stated in other issues on this project. It's geared toward Windows with a bit of *nix sprinkled in and recommends some horrible practices in regards to security.
whoami is a command you can use to see what user you're running a terminal/shell session as. Is that the same as the user that runs/owns nginx? (Most likely not but doesn't hurt to check)
just install run
apt-get install php5-fpm
And you are getting php5-fpm, but you NEED to proxy all Request to PHP-files to PHP-FPM
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/www.sock|fcgi://127.0.0.1:9000/PATH/TO/DOCUMENTROOT/ retry=1
EDIT! Forgot that OP is using Nginx and not apache
@jwshields yeah sorry forgot the 5, ran it this morning without my coffee.
I did notice that its now showing errors trying to run a PHP file in console now, im not sure why it didn't yesterday, strange.
Why in https://github.com/webbukkit/dynmap/issues/2027 do you recommend to change the socket from UNIX to TCP/IP?
I don't know how im struggling so much with this, I installed php5-fpm and uncommented the php lines in the nginx config (Not the proxy), and reloaded the web server. but I cant even get a phpinfo(); page to load, nginx shows "An error occurred" https://map.piratemc.com/index.php
Here is my Nginx config, I followed https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04#step-3-install-php-for-processing
But that config was different to mine, so I just uncommented the lines in mine, also I don't have a sites-enabled, all my data is saved in conf.d.
I also set cgi.fix_pathinfo=0 as recommended.
I've gotten some questions about tcp vs unixsockets. personally I prefer TCP, but the performance benefit you get for a unix socket is negligible. I just included it in there because that was something I did in my config. (What I mean is, it does not matter and is personal preference)
Your nginx config looks "okay"
I believe that line 45 might cause some issues?
Also, it is not recommended to define multiple root directories (such as you have on line 42) [ https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#root-inside-location-block ]
Here is my PHP location block: https://pastebin.com/P9ib981t
And here is my fastcgi_params / fastcgi.conf file: https://pastebin.com/yJCXWtjk
Here's my full nginx config for one vhost, https://pastebin.com/kRp2BZb1
My bet is that line 45 is what's throwing off your config.
Otherwise I think everything else is more or less okay.
@jwshields I thought that and I also tested hashing out that root, I also tried it with the path, Im just using the defaults. Ill remove it from 42.
I have no idea what to change 45 to, thats the default. It seems running php index.php from the commandline works, so it must be nginx!
I edited your config to be similar to mine; This should be working afaik. It's basically a clone of my working config except with your directories and files subbed in. I commented out some things like the log files and some ssl parameters, work those to your needs.
Also, could you verify if php is running? IE, netstat -ntlp | grep 9000
When I open your site I get a 502 error, which means Nginx is having problems talking to the backend/upstream PHP server.
Anyway, here's the config, https://pastebin.com/GiuBQ1iG
Edit: I removed some of the comments from your original to cut down on text, too.
BTW- with the SSL configuration, you should score at least 90 / A+ on SSLLabs (if you care about that sort of thing)
Edit 2: Also, regarding line 45 in your config, usually that is specified in the fastcgi_params file; on my config, line 45 is the include for that file;
Here is my fastcgi_params: https://pastebin.com/yJCXWtjk
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Specifically line 1 is what we're talking about. afaik this should be fairly secure.
@jwshields
Your config is a little different to mine as your OS generates a sites-enabled, mine does not, all configs are inside conf.d, and it seems uses different variables.
After looking at /var/log/nginx my error.log shows:
2017/03/02 15:19:22 [crit] 11965#11965: *63 connect() to unix:/var/run/php5-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 01.01.01.100, server: map.piratemc.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "map.piratemc.com"
What user is php running as? Seems like Nginx doesn't have perms to open the sock file.
A quick google pulled this result: http://stackoverflow.com/a/23487409/3508544
@FrozenBeard PHP7 will work well with Dynmap. The only compatibility issue comes up when you want people to be able to log in or register to the map. To fix this, you can apply this PR (which mike didn't merge... I still don't know why).
I'm using PHP7 on my webserver, and everything works well.
From what I remember, you need to give webserver permission to write in ./web/standalone directory if you want to enable the Dynmap chat feature.
@jwshields @SimonOrJ I made a bit of headway, I changed the /etc/nginx/nginx.conf "user" to www-data, as it was nginx before, reloaded and now I get a white page for the index.php, even though its got a print in it that works from terminal, Now I have to figure out why its displaying a white page and nothing else and no errors.
So I presume its something to do with how the script is run, I have tried many random things, induing ones posted here (hashed out) Heres my current default.conf
http://pastebin.com/iHQKai2R
I cannot believe how much hassle this is. I see why people stick to Apache now, Nginx is a massive pain in the ass.
What OS are you running? It shouldn't be that much of a hassle to set up. I am on Ubuntu 16.0.4, and everything I needed were in the default repository with correct configuration.
Try applying this in the \.php$ block (provided that you're using php-fpm (php7) and /etc/nginx/snippets/fastcgi-php.conf file exists):
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
If you're using php5, try listing directory of /run/php/ and find the similar unix socket thing.
All the webserver needs to access and run php scripts is read permission to the (.php) files. The user change may not have been necessary, but having it www-data does help with consistency.
P.S. I'm at work internet, and work internet blocked pastebin :c
I figured it out, I neeed 2 things, I needed
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
and I needed to move the "root" variable to the server section, $document_root didn't have a "root" set and didn't inherit this from the location area.
I highly suggest reading this for more information http://nginxlibrary.com/resolving-no-input-file-specified-error/
Now that I have nginx with PHP-Fpm running in http/2 with SSL, I can finally systemlink dynmap and try it again, wish me luck.
Looks like I have it working https://map.piratemc.com 馃
Thank you everyone for your help, its much appreciated.
Most helpful comment
As jwshields says, missing PHP is the issue. I used this guide to get PHP set-up. You can skip the mysql parts if you don't need MySQL server on the server.
The PHP files are there, but the current setup doesn't let nginx know how to take care of .php files.