2
votes

I've got stuck with this problem for 3 days.
My Server is Centos, and use wordpress (WP) in Httpd service.
Its IP is '103.232.120.178'
I want to use nginx as reverse proxy for WP.

Httpd is in port 2101
Nginx is in port 80
WP is in sub directory: 'bongda69' (url: '103.232.120.178:2101/bongda69')

I want if visit mywebsite, it redirect to wordpress.
Ex: visit '103.232.120.178', it will display as WP site: '103.232.120.178:2101/bongda69'

My nginx.conf is:


    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
    

and in General Settings in WP, I configure:


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

But, when visit 'http://103.232.120.178', error display:

    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.

If I configure nginx like this:


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

Everything is Okie. But I must visit site "http://103.232.120.178/bongda69", and I don't want it.

What is my mistake?
Anyone can help me?
Thanks a lott!!!

1

1 Answers

0
votes

This should work

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

I suggest adding

/var/log/nginx/access.log; 

in order to see whats happens with your request