search

Home  >  Q&A  >  body text

Please ask the nginx agent for forwarding and a complete online information, please!

The current situation is like this, my nginx is configured!
But I am not familiar with forwarding, and I have not been successful in finding information!

I have A domain name www.a.cn main website

Then the request from main site A has to go to sites B and C. Since the second-level domain name is cross-domain, please complete the front-end and back-end requests!

I want to forward
www.a.cn/api/xxx/xx
to
api.a.cn/api/xxx/xx

Forward
www.a.cn/user/xxx/xx
to
api.a.cn/user/xxx/xx

Forward
www.a.cn/mch/xxx/xx
to
mch.a.cn/mch/xxx/xx

Thank you everyone, who has complete nginx configuration information online?

某草草某草草2771 days ago894

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-06-26 10:51:59

    server {
        listen 80;
        server_name www.a.cn;
        index index.html index.htm index.php;
        root 网站根目录;
        
        location /api {
           proxy_pass http://api.a.cn;
        }
        
        location /user {
            proxy_pass http://api.a.cn;
        }
        
        location /mch {
            proxy_pass http://mch.a.cn;
        }
    }

    Try it

    reply
    0
  • Cancelreply