Nginx For Windows 路由配置
Nginx For Windows 路由配置
- 一、路由配置說明
- 二、需求說明
- 三、配置文件
一、路由配置說明
使用Nginx進(jìn)行路由配置。
使用過 SpringCloud 網(wǎng)關(guān)的同學(xué)都知道,網(wǎng)關(guān)可以使用同一IP地址、同一端口號(hào)、不同的服務(wù)ID,轉(zhuǎn)發(fā)不同服務(wù)API信息,不會(huì)出現(xiàn)跨域的問題。
SpringCloud Gateway 的默認(rèn)路由規(guī)則:http://Gateway_HOST:Gateway_PORT/大寫的serviceId/xxx
如:
http://192.168.1.1:8080/USER-API/ 轉(zhuǎn)發(fā)到 http://192.168.1.200:9090/
http://192.168.1.1:8080/CAR-API/ 轉(zhuǎn)發(fā)到 http://192.168.1.201:9092/
http://192.168.1.1:8080/ORDER-API/ 轉(zhuǎn)發(fā)到 http://192.168.1.202:9094/
二、需求說明
監(jiān)控本地服務(wù)器的 9000 端口,根據(jù)不同的URL路徑,轉(zhuǎn)發(fā)到不同的網(wǎng)絡(luò)地址。
http://127.0.0.1:9000/t1/ 轉(zhuǎn)發(fā)到 http://127.0.0.1:9001/
http://127.0.0.1:9000/t2/ 轉(zhuǎn)發(fā)到 http://127.0.0.1:9002/
http://127.0.0.1:9000/baidu/ 轉(zhuǎn)發(fā)到 https://www.baidu.com/
三、配置文件
完整配置文件如下,測(cè)試可用
#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/;}} }總結(jié)
以上是生活随笔為你收集整理的Nginx For Windows 路由配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Mysql5.0没有nvarchar,n
- 下一篇: 使用onclick跳转到其他页面/跳转到