转发http的方式
http{
proxy_read_timeout 300s; # 超时时间5分钟
proxy_send_timeout 300s;
keepalive_requests 1000;
keepalive_timeout 300s;
server{
listen 8888; # 监听端口8888 跳转到下面地址
location / {
proxy_pass http://192.168.1.20:8080;
}
}
}
转发tcp的方式
# 通过3000端口访问本机的mysql
events {
use epoll;
worker_connections 1024;
}
stream {
server {
listen 3000;
proxy_pass 127.0.0.1:3306;
# 也支持socket
# proxy_pass unix:/var/lib/mysql/mysql.socket;
}
}