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;
    }
}
posted @ 2022-01-13 12:07  花酒锄作田  阅读(112)  评论(0编辑  收藏  举报