search

Home  >  Q&A  >  body text

nginx configuration reverse generation problem

Can I use simple nginx syntax to set up proxies in different directories?
For example

server
{
	listen 80;
	server_name xxx.com;
	location /baidu {
		proxy_redirect off;
		proxy_set_header Accept-Encoding "";
		proxy_set_header Host "baidu.com";
		proxy_set_header X-Real-IP $remote_addr;
		proxy_pass http://baidu.com;
}

Visit xxx.com/baidu and the agent will be baidu.com

Can we use set to access xxx.com/abc and the proxy is abc.com? Will it automatically proxy different websites according to different directories?
How to achieve it?

ringa_leeringa_lee2755 days ago609

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-05-16 17:24:19

    Can you describe it in detail? . . I don't quite understand what your needs are. . If you want to proxy different websites based on different directories. . . It is not good to use nginx proxy. . . You can write routing in your program. . . .

    reply
    0
  • Cancelreply