1.创建配置文件 ext.conf
-
-
server {
-
listen
8011;
# 访问端口
-
server_name localhost;
-
#charset koi8-r;
-
#access_log /var/log/nginx/host.access.log main;
-
-
location / {
-
proxy_pass http:
//192.168.100.135:8011/; # 代理接口地址
-
proxy_set_header Host $host;
-
proxy_set_header X-Real-IP $remote_addr;
-
proxy_set_header x_real_ipP $remote_addr;
-
proxy_set_header remote_addr $remote_addr;
-
proxy_set_header X-Forwarded-
For $proxy_add_x_forwarded_for;
-
proxy_http_version
1.1;
-
proxy_connect_timeout
300s;
-
proxy_read_timeout
300s;
-
proxy_send_timeout
300s;
-
proxy_set_header Upgrade $http_upgrade;
-
proxy_set_header Connection upgrade;
-
}
-
#error_page 404 /404.html;
-
# redirect server error pages to the static page /50x.html
-
#
-
error_page
500
502
503
504 /
50x.html;
-
location = /
50x.html {
-
root /usr/share/nginx/html;
-
}
-
}
-
-
server {
-
listen
8088;
# 访问端口
-
server_name localhost;
-
#charset koi8-r;
-
#access_log /var/log/nginx/host.access.log main;
-
-
location /cluster {
-
proxy_pass http:
//192.168.100.103:8088/cluster/; # 代理接口地址
-
proxy_set_header Host $host;
-
proxy_set_header X-Real-IP $remote_addr;
-
proxy_set_header x_real_ipP $remote_addr;
-
proxy_set_header remote_addr $remote_addr;
-
proxy_set_header X-Forwarded-
For $proxy_add_x_forwarded_for;
-
proxy_http_version
1.1;
-
proxy_connect_timeout
300s;
-
proxy_read_timeout
300s;
-
proxy_send_timeout
300s;
-
proxy_set_header Upgrade $http_upgrade;
-
proxy_set_header Connection upgrade;
-
}
-
location /logs {
-
proxy_pass http:
//192.168.100.103:8088/logs/; # 接口地址
-
proxy_set_header Host $host;
-
proxy_set_header X-Real-IP $remote_addr;
-
proxy_set_header x_real_ipP $remote_addr;
-
proxy_set_header remote_addr $remote_addr;
-
proxy_set_header X-Forwarded-
For $proxy_add_x_forwarded_for;
-
proxy_http_version
1.1;
-
proxy_connect_timeout
300s;
-
proxy_read_timeout
300s;
-
proxy_send_timeout
300s;
-
proxy_set_header Upgrade $http_upgrade;
-
proxy_set_header Connection upgrade;
-
}
-
-
#error_page 404 /404.html;
-
# redirect server error pages to the static page /50x.html
-
#
-
error_page
500
502
503
504 /
50x.html;
-
location = /
50x.html {
-
root /usr/share/nginx/html;
-
}
-
}
-
-
-
2.将配置文件存放到指定配置文件目录
/etc/nginx/conf.d
本文采用的 nginx 是用 yum 安装的,所以配置文件路径目录是/etc/nginx/conf.d.
3.重新加载配置文件
3.1.运行
nginx
3.2. 重新加载配置文件
nginx -s reload3.3. 验证配置文件
nginx -t3.4.停止
nginx -s stop
转载:https://blog.csdn.net/zhanglong_4444/article/details/104275553
查看评论