By Rhys19
I have installed NGINX on my ubuntu 16.04 VPS for an external web program called Pterodactyl and when i went to access the site where i needed to go to their admin panel it showed
502 Bad Gateway
nginx/1.12.1 (Ubuntu)
Steps i did: nginx -t
OUTPUT:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
then i restarted the vps after it booted i did service nginx status output:
root@HSH-VPS:~# service nginx status
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
Active: active (running) since Mon 2018-07-02 01:14:51 UTC; 21min ago
Docs: man:nginx(8)
Process: 1631 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 -
Process: 1644 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code
Process: 1632 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process
Main PID: 1646 (nginx)
Tasks: 3 (limit: 4915)
Memory: 4.0M
CPU: 61ms
CGroup: /system.slice/nginx.service
├─1646 nginx: master process /usr/sbin/nginx -g daemon on; master_pro
├─1647 nginx: worker process
└─1648 nginx: worker process
Jul 02 01:14:51 HSH-VPS systemd[1]: Starting A high performance web server and a
Jul 02 01:14:51 HSH-VPS systemd[1]: Started A high performance web server and a
then i restarted nginx and again with the 502 error now when pterodactyl installs it creates and enables HTTPS for the ip address/the domain you assigned so i thought maybe if i add a firewall and allow port 443 and allowed https but that didn’t solve it any ideas?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Your output log shows that nginx has a valid config file, and is running OK.
In this scenario, a 502 Error often means the web server (nginx) could handle and respond to the request just fine, but the application (pterodactyl, running via PHP-FPM) is broken or not properly configured and not connectable from nginx.
Look at the nginx error logs (based on pterodactyl documentation, they’ll be here: /var/log/nginx/pterodactyl.app-error.log if you don’t find anything there, try the default nginx error logs at /var/log/nginx/error.log
Any clues in that log?
Also - I wouldn’t recommend ONLY allowing port 443 via firewall, because users who try and go to the non-secure http version of your url’s won’t get redirected to HTTPS, they’ll just get an error. So ideally you want to allow ports 80 and 443
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.