Welcome! Log In Create A New Profile

Advanced

Wordpress-mu gives 502 Bad Gateway

Posted by tsl 
tsl
Wordpress-mu gives 502 Bad Gateway
June 08, 2009 02:51AM
Hi,

We run wpmu 2.6.3 on apache with subdomains, domain mapping and wp super cache.
Centos 5.3
httpd-2.2.3-22
php-5.1.6
mysql-5.0.45-7

The blogs are under heavy traffic in the evenings which causes a huge serverload from time to time.
We would really like to switch to nginx since it seems that it would really boost the performance.
However, I spent all day yesterday trying to migrate to nginx with no success.
When trying to login to blogs (/wp-admin) I always recieve a "502 Bad Gateway" and in the error_log is this:

[code]
2009/06/08 01:58:35 [error] 30293#0: *57810 recv() failed (104: Connection reset by peer) while reading
response header from upstream, client: 92.254.169.32, server: my.wpmu.tld, request:
"GET /wp-admin/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000",
[/code]


The blogs however seems to work fine and the wp super cache is working too.

Here's the nginx virtual.conf

[code]
server {
listen my.wpmu.tld:80;
server_name my.wpmu.tld *.my.wpmu.tld;
server_name_in_redirect off;

location / {
root /srv/www/wpmu;
index index.php index.html;


# WP and Super Cache
if (-f $request_filename) {
break;
}

if (-d $request_filename) {
break;
}

rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1;

if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
#rewrite ^(.+)$ /index.php?q=$1 last;
}

set $supercache_file .;
set $supercache_uri $request_uri;

if ($request_method = POST) {
set $supercache_uri .;
}

if ($query_string) {
set $supercache_uri .;
}

if ($http_cookie ~* .comment_author_|wordpress|wp-postpass_. ) {
set $supercache_uri .;
}

if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}

if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}


location ~ \.php {
root /srv/www/wpmu;
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
}
}
}

[/code]

Here's the fastcgi.conf

[code]
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;
[/code]

I have tried many different configs with and without wp super cache but always the same "502 Bad Gateway" when trying to login.

I hope I have done something wrong or missed something vital out. We would love to get nginx working with our wpmu, I actually believe this is our only way forward.

I have a standalone WP install on the same server which is working fine with the following nginx conf:
[code]
server {
listen 80;
listen spotlife.se:80;
server_name singlewp.tld www.singlewp.tld;

location / {
root /srv/www/singlewp.tld;
index index.php index.html;
rewrite ^/login(.*) /wp-admin redirect;


# WP

rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1;
if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}


location ~ \.php {
root /srv/www/singlewp.tld;
fastcgi_index index.php;
include /etc/nginx/conf.d/fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
}

[/code]


Many thanks in advance for your thoughts and idéas.
-tsl-



Edited 1 time(s). Last edit at 06/08/2009 02:57AM by tsl.
Re: Wordpress-mu gives 502 Bad Gateway
August 09, 2009 04:00AM
Hello sir, were you able to fix the issue? I am having exactly the same problems with my NGINX + Wordpress Mu Installation :( Thanks.
tsl
Re: Wordpress-mu gives 502 Bad Gateway
August 09, 2009 05:13AM
Hi trav85,

No I still had the issue so I reverted back to apache again. Though I would really need to get it to work since we need the performance gain from Nginx.

Thanks
-tsl-
Re: Wordpress-mu gives 502 Bad Gateway
October 18, 2009 08:42PM
did you ever get this to work?? i am having the same problem.... if i run a clean install on the local machine it works...but if I use nfs server to exsisting system i get 502 bad gateway?

Id pay a huge fee if someone can get this to work for us

dthreatt@digitalcreations.net
tsl
Re: Wordpress-mu gives 502 Bad Gateway
October 19, 2009 02:33AM
No sorry, will have another go in a month or two. If you're able to get it to work please post the resolution here.
Thanks
-tsl-
Re: Wordpress-mu gives 502 Bad Gateway
December 03, 2009 12:14PM
Hi, Wordpress MU is working fine over my nginx server
Here's my wpmu main blog configuration:

server {
listen 80;
server_name wpmudomain.com www.wpmudomain.com;
access_log logs/wpmudomain.com.access.log main;

location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /var/www/vhosts/wpmudomain.com/htdocs;
rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$
/wp-content/blogs.php?file=$1 last;
expires 30d;
break;
}

location / {
root /var/www/vhosts/wpmudomain.com/htdocs;
index index.php;

if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
error_page 500 502 503 504 /50x.html;

location = /50x.html {
root /var/www/nginx-default;
}

location ~ \.php$ {
rewrite ^/.*(/wp-.*/.*.php)$ $1;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/vhosts/wpmudomain.com/htdocs$fastcgi_script_name;
include fastcgi_params;
}
}

No I'm trying to make it work with the domain mapping plugin but it does not work!
tsl
Re: Wordpress-mu gives 502 Bad Gateway
December 04, 2009 02:38AM
Hi antoinet, what does not work with the domainmapping?

Are you running wp-super-cache in your install?

I still haven't been able to solved the mu/wp-super-cache/nginx issues. Now and then I get a "502 Bad Gateway".
To bad, the performance over apache and the ability to stand ddos that nginx has we really need.

Latest conf below

This is the /etc/nginx/nginx.conf for the default server:

[code]
#
# The default server
#
server {
listen ip.add.re.ss:80;
server_name _;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root /var/www/html;
index index.html index.htm;
}

error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
[/code]

This is /etc/nginx/conf.d/fastcgi.conf:

[code]
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;
[/code]

This is the vhost conf for the wpmu install /etc/nginx/conf.d/vhost.conf:

[code]
server {
listen ip.add.re.ss:80;
server_name my.domain.tld *.my.domain.tld;
server_name_in_redirect off;

charset utf-8;

index index.php;
root /srv/www/my.domain.tld/;

#access_log /var/log/nginx/my.domain.tld_access.log;
access_log /dev/null;
error_log /var/log/nginx/my.domain.tld_error.log;

# rewrite rule - fancy urls for wordpress mu

rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1;

if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
#error_page 404 = /index.php?q=$uri;

include /etc/nginx/wordpress_params.super_cache;
#include /etc/nginx/wordpress_params.regular;


# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SCRIPT_FILENAME /srv/www/my.domain.tld/$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
}
}
[/code]

This is the /etc/nginx/wordpress.params.super_cache

[code]
if (-f $request_filename) {
break;
}

set $supercache_file '';
set $supercache_uri $request_uri;

if ($request_method = POST) {
set $supercache_uri '';
}

# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {
set $supercache_uri '';
}

if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache_uri '';
}

# if we haven't bypassed the cache, specify our supercache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}

# only rewrite to the supercache file if it actually exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}

# all other requests go to Wordpress
if (!-e $request_filename) {
rewrite . /index.php last;
}
[/code]



-tsl-
Re: Wordpress-mu gives 502 Bad Gateway
April 26, 2010 11:51AM
tsl Wrote:
-------------------------------------------------------
> Hi,
>
> We run wpmu 2.6.3 on apache with subdomains,
> domain mapping and wp super cache.
> Centos 5.3
> httpd-2.2.3-22
> php-5.1.6
> mysql-5.0.45-7
>
> The blogs are under heavy traffic in the evenings
> which causes a huge serverload from time to time.
> We would really like to switch to nginx since it
> seems that it would really boost the performance.
> However, I spent all day yesterday trying to
> migrate to nginx with no success.
> When trying to login to blogs (/wp-admin) I always
> recieve a "502 Bad Gateway" and in the error_log
> is this:
>
>
> 2009/06/08 01:58:35 30293#0: *57810 recv() failed
> (104: Connection reset by peer) while reading
> response header from upstream, client:
> 92.254.169.32, server: my.wpmu.tld, request:
> "GET /wp-admin/ HTTP/1.1", upstream:
> "fastcgi://127.0.0.1:9000",
>
>
>
> The blogs however seems to work fine and the wp
> super cache is working too.
>
> Here's the nginx virtual.conf
>
>
> server {
> listen my.wpmu.tld:80;
> server_name my.wpmu.tld *.my.wpmu.tld;
> server_name_in_redirect off;
>
> location / {
> root /srv/www/wpmu;
> index index.php index.html;
>
>
> # WP and Super Cache
> if (-f $request_filename) {
> break;
> }
>
> if (-d $request_filename) {
> break;
> }
>
> rewrite ^.*/files/(.*)
> /wp-content/blogs.php?file=$1;
>
> if (!-e $request_filename) {
> rewrite ^.+/?(/wp-.*) $1 last;
> rewrite ^.+/?(/.*\.php)$ $1 last;
> #rewrite ^(.+)$ /index.php?q=$1 last;
> }
>
> set $supercache_file .;
> set $supercache_uri $request_uri;
>
> if ($request_method = POST) {
> set $supercache_uri .;
> }
>
> if ($query_string) {
> set $supercache_uri .;
> }
>
> if ($http_cookie ~*
> .comment_author_|wordpress|wp-postpass_. ) {
> set $supercache_uri .;
> }
>
> if ($supercache_uri ~ ^(.+)$) {
> set $supercache_file
> /wp-content/cache/supercache/$http_host/$1index.ht
> ml;
> }
>
> if (-f $document_root$supercache_file) {
> rewrite ^(.*)$ $supercache_file break;
> }
>
>
> location ~ \.php {
> root /srv/www/wpmu;
> fastcgi_index index.php;
> fastcgi_pass 127.0.0.1:9000;
> }
> }
> }
>
>
>
> Here's the fastcgi.conf
>
>
> fastcgi_param GATEWAY_INTERFACE CGI/1.1;
> fastcgi_param SERVER_SOFTWARE nginx;
> fastcgi_param QUERY_STRING $query_string;
> fastcgi_param REQUEST_METHOD $request_method;
> fastcgi_param CONTENT_TYPE $content_type;
> fastcgi_param CONTENT_LENGTH $content_length;
> fastcgi_param SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
> fastcgi_param SCRIPT_NAME $fastcgi_script_name;
> fastcgi_param REQUEST_URI $request_uri;
> fastcgi_param DOCUMENT_URI $document_uri;
> fastcgi_param DOCUMENT_ROOT $document_root;
> fastcgi_param SERVER_PROTOCOL $server_protocol;
> fastcgi_param REMOTE_ADDR $remote_addr;
> fastcgi_param REMOTE_PORT $remote_port;
> fastcgi_param SERVER_ADDR $server_addr;
> fastcgi_param SERVER_PORT $server_port;
> fastcgi_param SERVER_NAME $server_name;
> fastcgi_param REDIRECT_STATUS 200;
>
>
> I have tried many different configs with and
> without wp super cache but always the same "502
> Bad Gateway" when trying to login.
>
> I hope I have done something wrong or missed
> something vital out. We would love to get nginx
> working with our wpmu, I actually believe this is
> our only way forward.
>
> I have a standalone WP install on the same server
> which is working fine with the following nginx
> conf:
>
> server {
> listen 80;
> listen spotlife.se:80;
> server_name singlewp.tld www.singlewp.tld;
>
> location / {
> root /srv/www/singlewp.tld;
> index index.php index.html;
> rewrite ^/login(.*) /wp-admin redirect;
>
>
> # WP
>
> rewrite ^.*/files/(.*)
> /wp-content/blogs.php?file=$1;
> if (!-e $request_filename) {
> rewrite ^.+?(/wp-.*) $1 last;
> rewrite ^.+?(/.*\.php)$ $1 last;
> rewrite ^ /index.php last;
> }
>
>
> location ~ \.php {
> root /srv/www/singlewp.tld;
> fastcgi_index index.php;
> include /etc/nginx/conf.d/fastcgi.conf;
> fastcgi_pass 127.0.0.1:9000;
> }
> }
> }
>
>
>
>
> Many thanks in advance for your thoughts and
> idéas.
> -tsl-


Is this fixed already? Been using WP for years but I just encountered it now when I try to associate it with nginx. Any ideas or people know how to solve this? Thanks in advance..
Re: Wordpress-mu gives 502 Bad Gateway
April 26, 2010 11:54AM
Hello guys. is this already solve? I've been using wordpress for a year already and just encounter a 502 bad gateway problem when I try to associate it with nginx. Any idea about this and would be glad if someone could help us with this. Thank you.

"I can accept failure, everyone fails at something. But I can't accept not trying."
Editor @ [url=http://www.daily-reviews.com]Daily Reviews[/url]
tsl
Re: Wordpress-mu gives 502 Bad Gateway
April 26, 2010 11:57AM
No sorry, we tried one more time and it worked for a week or two and then we got the 502 bad gateway intermittently.
Sorry to say but we have now abandoned nginx for our current plattform
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 301
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready