nginx配置代理端口

1、server为我们当前要配配置的ip以及代理端口号

server{ listen 80; server_name localhost; }

2、location为我们需要代理的ip设置,包括重写,设置超时等等。

localtion /api { rewrite '^/xxl-job-admin/(.*)' /api/$1; proxy_pass http://172.31.14.168:8080/xxl-job-admin }
(.*)'.表示任意除n\字符之外的任意字符 *表示可0次或者多次出现匹配'
rewrite为重写url设置,表示我们访问/xxl-job-admin时,重写前缀为/api
这样就可以访问localhost来访问172.31.14.168:8080了

3、root指向根路径下的static文件夹 默认渲染index.html页面

、
location / {
root static;
index index.html;
}`

4、nexin -T 打印当前的输入配置,用来检配置是否有误,以及乱码报错
posted @ 2020-08-29 00:10  yuanhonglin  阅读(10080)  评论(0)    收藏  举报