Nginx For Windows 路由配置
生活随笔
收集整理的這篇文章主要介紹了
Nginx For Windows 路由配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Nginx For Windows 路由配置
- 一、路由配置說明
- 二、需求說明
- 三、配置文件
一、路由配置說明
使用Nginx進行路由配置。
使用過 SpringCloud 網關的同學都知道,網關可以使用同一IP地址、同一端口號、不同的服務ID,轉發不同服務API信息,不會出現跨域的問題。
SpringCloud Gateway 的默認路由規則:http://Gateway_HOST:Gateway_PORT/大寫的serviceId/xxx
如:
http://192.168.1.1:8080/USER-API/ 轉發到 http://192.168.1.200:9090/
http://192.168.1.1:8080/CAR-API/ 轉發到 http://192.168.1.201:9092/
http://192.168.1.1:8080/ORDER-API/ 轉發到 http://192.168.1.202:9094/
二、需求說明
監控本地服務器的 9000 端口,根據不同的URL路徑,轉發到不同的網絡地址。
http://127.0.0.1:9000/t1/ 轉發到 http://127.0.0.1:9001/
http://127.0.0.1:9000/t2/ 轉發到 http://127.0.0.1:9002/
http://127.0.0.1:9000/baidu/ 轉發到 https://www.baidu.com/
三、配置文件
完整配置文件如下,測試可用
#user nobody; worker_processes 1;#error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;#pid logs/nginx.pid;events {worker_connections 1024000; }http {server {listen 9000;server_name localhost;location /t1/ {proxy_pass http://127.0.0.1:9001/;}location /t2/ {proxy_pass http://127.0.0.1:9002/;}location /baidu/ {proxy_pass https://www.baidu.com/;}} }總結
以上是生活随笔為你收集整理的Nginx For Windows 路由配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Mysql5.0没有nvarchar,n
- 下一篇: 使用onclick跳转到其他页面/跳转到