nginx反向代理常用基本配置
http反向代理
http {
...
server {
listen 80;
location / {
proxy_pass http://192.168.0.10:80;
}
}
}
tcp反向代理
stream {
server {
listen 81;
location / {
proxy_pass 192.168.0.11:81;
}
}
}
udp反向代理
stream {
server {
listen 82 udp;
location / {
proxy_pass 192.168.0.12:82;
}
}
}
websocket反向代理
upstream backend {
server 192.168.0.13:83;
}
server {
listen 83;
server_name localhost;
location / {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
gRPC反向代理
http {
server 84 http2;
location / {
grpc_pass grpc://192.168.0.14:84;
}
}
本文来自博客园,作者:花酒锄作田,转载请注明原文链接:https://www.cnblogs.com/XY-Heruo/p/15797057.html