Home  >  Q&A  >  body text

Does nginx proxy forwarding fail?

Configure a virtual host directly in nginx.conf to implement proxy forwarding and test OK, as follows:

server
{
    listen       80;
    listen         443;
    server_name  yangbai.com;
    root  /Library/WebServer/Documents/yangbai;
    index  index.php;
    location / {
        #root    /Library/WebServer/Documents/youzan_oa/yzOA/src;
        index   index.html index.htm login.html;
    }

    location   /oauth/token {
       proxy_pass     http://api.yangbai.com;
    }
}

Test: http://yangbai.com/oauth/token successfully proxy to http://api.yangbai.com

But I extracted the above configuration and placed it under the servers directory at the same level as nginx.conf. I named yangbai.com.conf and the content was the same as above. Then nginx.conf was loaded through include servers/*;, but The test has never been able to be proxied. . . Brothers and sisters passing by, please take a look. I am not very familiar with nginx configuration.

大家讲道理大家讲道理2713 days ago612

reply all(1)I'll reply

  • 習慣沉默

    習慣沉默2017-05-16 17:19:00

    Write the complete path of

    include, for example:

    include /usr/local/nginx/conf.d/*.ngx.conf;

    reply
    0
  • Cancelreply