首页 文章

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

提问于
浏览
1

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

Httpd位于端口2101中
Nginx在80端口
WP位于子目录中:'bongda69'(url:'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/;
            }

一切都是Okie . 但我必须访问网站“http://103.232.120.178/bongda69”,我不想要它 .

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

1 回答

  • 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
    

    added

    我建议补充一下

    /var/log/nginx/access.log;
    

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

相关问题