Reverse-proxy NGINX + Apache on Directadmin powered server with CB 2.x

You should read nginx error logs for details in /var/log/nginx/ and check output of:

Code:
/etc/init.d/nginx -t

Probably you need to encrease server_names_hash_max_size or server_names_hash_bucket_size.
 
You should read nginx error logs for details in /var/log/nginx/ and check output of:

Code:
/etc/init.d/nginx -t

Probably you need to encrease server_names_hash_max_size or server_names_hash_bucket_size.

i recompile with Nginx and run the command
/etc/init.d/nginx restart -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Stopping nginx:
Starting nginx: [ OK ]

i cannot see any error in the log :

014/11/12 07:52:14 [notice] 19349#0: signal process started

but still i get 502 Bad Gateway error

so i again revert to apache :(
 
A problem i regulary have is when nginx isn't stopped correctly it won't start.

When you see
Stopping nginx:
Starting nginx: [ OK ]

You can try
service nginx status
if that one is saying running kill the pid.

kill ******

where ***** is the pid number.

Then go and type
service nginx restart
Then the following output will be generated

Stopping nginx: [ Failed ]
Starting nginx: [ OK ]
 
502 usually means that there is no response from Apache. Please check:
Code:
ps auxw | grep httpd
httpd -t
 
A problem i regulary have is when nginx isn't stopped correctly it won't start.

When you see
Stopping nginx:
Starting nginx: [ OK ]

You can try
service nginx status
if that one is saying running kill the pid.

kill ******

where ***** is the pid number.

Then go and type
service nginx restart
Then the following output will be generated

Stopping nginx: [ Failed ]
Starting nginx: [ OK ]

i did all you said but not difference : 502 Bad Gateway
 
502 usually means that there is no response from Apache. Please check:
Code:
ps auxw | grep httpd
httpd -t

there is no Problem with HTTPD as i said before applying be configuration nginx work but after this command the problem appears
/build rewrite_confs

"""the point is that before last step which is ./build rewrite_confs seems Nginx works fine but with default page (the welcome page of Nginx) but after i run ./build rewrite_confs , it get me always 502 bad gateway nginx error ""
 
If you'd like to, I could check&fix it on your server (free of charge).
 
Do you have mod_security enabled in Apache? In some cases it causes nginx to drop 502 error.
 
Can anyone point me to a basic configuration guide?

I am used to editing httpd-mpm.conf to set some memory-friendly limitations, but with this setup I guess there are probably three files to edit (and httpd-mpm.conf may not even be one of them). Thanks!
 
I ran a custom Nginx reverse proxy + Apache with DirectAdmin server before. Today we migrated the website to a new DirectAdmin server with the custombuild way of Apache + Nginx as reverse proxy. This gave me 2 questions:

- The Nginx reverse proxy has a configuration for "location /nginx_static_files/". Does it mean I have to create a folder nginx_static_files and put my static files in there? Because our static files are for example in folder "images" and with the default configuration the images were send by Nginx (I added "add_header Who Nginx;" to see which webserver is serving the files). However looking at Apache's server-status Apache was still serving (all?) the images, maybe to Apache or maybe to the user, but it was serving to something.

- I added the following code to CUSTOM3:
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$
{
root /home/<user>/domains/<domain>/public_html/;
add_header Who Nginx;
}

Now Nginx was really sending the images itselves and Apache didn't touch it.

Could someone explain the nginx_static_files part to me?
 
Does it mean I have to create a folder nginx_static_files and put my static files in there?

NO, never do it.

However looking at Apache's server-status Apache was still serving (all?) the images, maybe to Apache or maybe to the user, but it was serving to something.

That's true. The way custombuild sets nginx as a reverse proxy allows to respect .htaccess. Thus you may use mod_rewrite for static files, order,allow, etc.

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$
{
root /home/<user>/domains/<domain>/public_html/;
add_header Who Nginx;
}

Now Nginx was really sending the images itselves and Apache didn't touch it.

In this case you can not use .htaccess file to restrict access to the static files. Please read this https://github.com/defanator/mod_aclr2 for more details.
 
Hi guys,

I've ran into the 502 bad gateway error. how to fix is?
I've had it twice so far, both times after tinkering with nginx/apache/php-fpm

First time it was NOT solved by restarting these three services, but a reboot did the trick.

Second time I had simply misconfigured apache, so apache wasn't running and nginx didn't know where to send the requests. Restart apache (and possibly php-fpm), and check the logs.
 
I've rebooted 4 times now and didnt work.
apache and nginx are running but theres no trace of php-fpm. How do I lookup the status of php-fpm? service php-fpm status throws an unrecognised service error.
 
It should be located here:

/etc/systemd/system/php-fpmXX.service

So you need to use XX instead of 56 ;)
 
directory does not exists.

I tried to get php-fpm working by running a custombuild, but stumbled upon 'php-fpm' is not supported with the nginx_apache webserver. Use mod_php instead.
 
Back
Top