路由器设置端口转发,nginx反向代理多个端口
多个Springboot项目在不同端口上运行,并通过不同路径传输到不同的端口http://127.0.0.1:8081/index
http://127.0.0.1:8082 /索引访问webB
http://127.0.0.1:8083 /索引访问webC
修改后:
访问http://127.0.0.1/a/indexWebA
http://127.0.0.1/b/indexwebb访问
http://127.0.0.1/c /索引webc访问
http { . upstream weba { server 127.0.0.133608081; } upstream Webb { server 127.0.0.1:8082; } upstream webc { server 127.0.0.1:8083; } . server { . location/a/{ proxy _ pass 3358 weba /; # proxy _ pass http://127.0.0.1:8081/#也可以直接写ip端口} location/b/{ proxy _ pass http://Webb /; } location/c/{ proxy _ pass 3358 webc/}…}访问某个路径直接跳转到新页面,然后输入http://127.0.0.1/blog,即可跳转到百度主页
位置^~~/blog { rewrite ^ https://www.Baidu.com; }位置和proxy_pass正斜线问题nginx proxy_pass末尾的不可思议正斜线
server.port=10240 @ request mapping (/a ) ) publicstringHelloa ) requestparamstringname ) { return 'Hello ' name! nowtime is ' newsimpledateformat (yyyy-mm-ddhh : mm : ss ).format ) system.currenttimemillis ); }服务是否在10240端口上运行并使用http://127.0.0.1:10240/a? 可以用name=123输出结果
是否要在proxy_pass后加上正斜杠来访问http://127.0.0.1/test1/a? name=123实际上要访问http://127.0.0.1:10240/a吗? name=123
因为location ^~/test1/{ proxy _ pass http://127.0.0.1336010240/} proxy _ pass后面没有斜杠,所以http://127.0.0.1/ttts name=123其实你在访问http://127.0.0.1:10240/test1/a吗? name=123
location ^~~/test1/{ proxy _ pass http://127.0.0.1336010240; }出现的问题unknownlogformat“main”Inc : (nginx-1.17.3/conf/nginx.conf :28
打开nginx.conf时,“main”错误丢失了log_format选项,因此以前阻止并修复了他以解决问题。
侦听80端口无效
包括/etc/nginx/sites-enabled/*; 评论,这个
nginx配置路由无效的问题
如何解决权限问题导致的Nginx 403 Forbidden错误
于是在nginx.conf的头上放上user root;
请参见在nginx的同一域名下放置多个项目