在CentOS中使用Nginx作为Apache上wordpress的反向代理

时间:2015-07-17 04:11:04

标签: linux wordpress apache nginx

我已经坚持了这个问题3天了 我的服务器是Centos,在Httpd服务中使用wordpress(WP) 它的IP是' 103.232.120.178'
我想使用nginx作为WP的反向代理。

Httpd位于端口2101中 Nginx在80端口 WP在子目录中:' bongda69' (网址:' 103.232.120.178:2101 / bongda69')

我想要访问mywebsite,它会重定向到wordpress 例如:访问' 103.232.120.178',它将显示为WP网站:' 103.232.120.178:2101 / bongda69'

我的nginx.conf是:


    user apache apache;
    worker_processes 4;

    error_log /var/log/nginx/error.log;

    events {
        worker_connections  1024;
    }

    http {

    upstream backend {
            server localhost:2101; # IP goes here.
        }

    server {
        listen 103.232.120.178:80; # IP goes here.

        location / {            
            proxy_pass http://backend/bongda69/;
            }
        } # End server
    } # End http
    

在WP中的常规设置中,我配置:


    WordPress Adress(URL): http://103.232.120.178/bongda69  
    Site Adress(URL): http://103.232.120.178/bongda69  

但是,当访问' http://103.232.120.178'时,错误显示:
    

    Not Found
The requested URL /index.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

如果我像这样配置nginx:


    location / {            
            proxy_pass http://backend/;
            }

一切都很好。但我必须访问网站" http://103.232.120.178/bongda69",我不想要它。

我的错误是什么?
有人可以帮帮我吗? 谢谢lott !!!

1 个答案:

答案 0 :(得分:0)

这应该有效

worker_processes 4;

error_log /var/log/nginx/error.log;

events {
  worker_connections  1024;
}

http {

  upstream backend {
    server 103.232.120.178:2101; # IP goes here.
  }

  server {
    listen 0.0.0.0:80; # IP goes here.

      location / { 
        proxy_pass http://backend/bongda69;
      }   
  } # End server
} # End http

<强>加入

我建议添加

/var/log/nginx/access.log; 

为了查看您的请求是否发生了什么