2

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 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

It doesn't work. I change proxy_pass to "backend/bongda69";, and if I visit "103.232.120.178/index.php";, it display: "Not Found The requested URL /bongda69index.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." And if I visit: "103.232.120.178";, it display: "This webpage has a redirect loop ERR_TOO_MANY_REDIRECTS"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.