• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Nginx BAD GATEWAY

Achraf

Basic Pleskian
Hello
Version Plesk v11.0.9_build os_CentOS 110120608.16 6
OS CentOS 6.2 (Final)

I have a problem with nginx, when one of my clients created a subdomain, then the execution of the creation of the subdomain if I click any link in a hosted sites I found an error message 502 bad gateway.

And even if I stop the service Nginx instead of an error page Baden Gateway 502, a browser error page is displayed.
 
Last edited:
Please try regenerating the vhosts for either only that domain name or the entire server with the commands

For all domains:

/usr/local/psa/admin/sbin/httpdmng --reconfigure-all

For a single domain name:
/usr/local/psa/admin/sbin/httpdmng --reconfigure-domain <domain_name>
 
Thank you for your reply,
Yes I have unlocked the problem temporarily with this command but the problem still persists.

Nb: for I avoid displaying BAD GATEWAY nginx I disabled the service Nginx, just after I executed your order for all customers, so that I avoid the display of the home page Plesk.
 
Last edited:
If you need to use Nginx really then I recommend the following:

1. Enable nginx from the SHELL by running the command

/usr/local/psa/admin/bin/nginxmng --enable

2. If sites open the default plesk page or apache's missing index file then you execute

/usr/local/psa/admin/sbin/httpdmng --reconfigure-all

Its Ok to restart both apache and nginx after the above with

/etc/init.d/httpd restart
/etc/init.d/nginx restart
 
Thank you for your support
- but the problem is still there
- the real problem is that if I created a subdomain for example at the same time if I click that link in any of the sites hosted in my server error page 502 Bad Gateway are displayed, and if I click refrech on the link to display correctly.
 
Hi,

I have the same problem. Is there already a solution? If I disable the NGINX, everything is OK, but if I enable it, I have the problems again.


CU
 
the real problem is that if I created a subdomain for example at the same time if I click that link in any of the sites hosted in my server error page 502 Bad Gateway are displayed, and if I click refrech on the link to display correctly.

I can assume that generation of nginx configs does not have time. We will check it.
 
Problem Solved.

This is the fix.

I have activated the nginx log in /etc/nginx/nginx.conf, then restart nginx.

I have found an error in /var/log/nginx/error.log like that "upstream sent too big header while reading response header from upstream"

I have been googling and the fix is to add some lines in nginx.conf file. Into the http directive add:

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

Restart nginx and ready
 
Problem Solved.

This is the fix.

I have activated the nginx log in /etc/nginx/nginx.conf, then restart nginx.

I have found an error in /var/log/nginx/error.log like that "upstream sent too big header while reading response header from upstream"

I have been googling and the fix is to add some lines in nginx.conf file. Into the http directive add:

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

Restart nginx and ready

Thank you for your answer
I tried but it does not work this solution
 
Problem Solved.

This is the fix.

I have activated the nginx log in /etc/nginx/nginx.conf, then restart nginx.

I have found an error in /var/log/nginx/error.log like that "upstream sent too big header while reading response header from upstream"

I have been googling and the fix is to add some lines in nginx.conf file. Into the http directive add:

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

Restart nginx and ready



Thanks a lot, this worked for me! :)
 
Dealing with Nginx

The very first thing you need to do is try to replicate the issue. Then check the ngnix logs at the following location :-

tail -f /var/log/nginx/error.log

If you notice an timeout error as below :-

2012/10/18 04:50:48 [error] 4647#0: *60825 upstream timed out (110: Connection timed out) while reading response header from upstream,

Execute following command from anywere on the server :-

mkdir -p /usr/local/psa/admin/conf/templates/custom/domain

cp -p /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/

This will copy the file called nginxDomainVirtualHost.php under custom/domain/ on the following path /usr/local/psa/admin/conf/templates/custom/domain/

the go to cd /usr/local/psa/admin/conf/templates/custom/domain/

vi nginxDomainVirtualHost.php

press / and paste proxy_set_header

and added

proxy_read_timeout 150;

before

proxy_set_header

Then For the change to be reflected on all vhosts in one go, you start one reconfigure-all :

/usr/local/psa/admin/bin/httpdmng --reconfigure-all

Hope that helps :D

Coolcap
 
Think you

d'ont work

The very first thing you need to do is try to replicate the issue. Then check the ngnix logs at the following location :-



If you notice an timeout error as below :-



Execute following command from anywere on the server :-





This will copy the file called nginxDomainVirtualHost.php under custom/domain/ on the following path /usr/local/psa/admin/conf/templates/custom/domain/

the go to cd /usr/local/psa/admin/conf/templates/custom/domain/



press / and paste proxy_set_header

and added

proxy_read_timeout 150;

before

proxy_set_header

Then For the change to be reflected on all vhosts in one go, you start one reconfigure-all :



Hope that helps :D

Coolcap
 
Try to set SELinux to Permissive and start httpd

Code:
sudo setenforce 0
sudo service httpd start

On my plesk 11.0.9, I've seen that after reboot, httpd did not start. Trying to start it manually gives

Code:
Starting httpd: (13)Permission denied: make_sock: could not bind to address [::]:7080
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:7080
no listening sockets available, shutting down

Syslog reports

Code:
setroubleshoot: SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket . For complete SELinux messages. run sealert -l d88dc295-a869-4537-bd19-d7f22e75ccde

sealert reports:

Code:
SELinux is preventing /usr/sbin/httpd from name_bind access on the tcp_socket .

*****  Plugin bind_ports (99.5 confidence) suggests  *************************

If you want to allow /usr/sbin/httpd to bind to network port 7080
Then you need to modify the port type.
Do
# semanage port -a -t PORT_TYPE -p tcp 7080
    where PORT_TYPE is one of the following: puppet_port_t, jboss_messaging_port_t, jboss_management_port_t, ntop_port_t, http_cache_port_t, http_port_t.

*****  Plugin catchall (1.49 confidence) suggests  ***************************

If you believe that httpd should be allowed name_bind access on the  tcp_socket by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep httpd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

I've tried to make a policy, but it seems it does not survive reboot.

I hate to keep SELinux in permissive mode, but right now, it seems there's not much I can do, unless you provide a solution to fix it.

If you need to keep SELinux in permissive mode until plesk provides a fix, you can edit /etc/sysconfig/selinux and change SELINUX to permissive
 
By the way... Error 502 does not mean a lot....

My error message from nginx was:

Code:
2012/11/16 10:28:28 [error] 2011#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: y.y.y.y, server: akim.sissaoui.com, request: "GET / HTTP/1.1", upstream: "http://x.x.x.x:7080/", host: "my.domain.com"

And while checking httpd status, I've discovered it was not started. Therefore, for sure, nginx could not forward requests to httpd.

Therfore, do not assume YOUR solution is THE solution to error 502. My guess is that there could be a lot of different solutions.
 
Works for me too

Problem Solved.

This is the fix.

I have activated the nginx log in /etc/nginx/nginx.conf, then restart nginx.

I have found an error in /var/log/nginx/error.log like that "upstream sent too big header while reading response header from upstream"

I have been googling and the fix is to add some lines in nginx.conf file. Into the http directive add:

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

Restart nginx and ready

This also worked for me! Thanks for sharing with everyone!
 
Non of these worked but changed scripting from using apache to Fast CGI and allowed me to export the database. I have also found this with permission problems on Wordpress installations.
 
Back
Top