Nginx转发
作者:互联网
Nginx 简单使用
1. nginx.conf 详解
stream
events
http
2. 常用命令
2.1 windows系统
在目录下输入cmd
查看版本
nginx -v
启动nginx
start nginx
关闭nginx
nginx -s stop
重新加载nginx配置
nginx -s reload
2.2 linux系统
从环境变量中的path文件中查找
查看版本
./nginx -v
启动nginx
./nginx
关闭nginx
./nginx -s stop
重新加载nginx配置
./nginx -s reload
3. 实现代理
3.1 代理端口
# 代理测试环境数据库
stream {
log_format logstash_json '{ "@timestamp": "$time_iso8601", '
'"@fields": { '
'"remote_addr": "$remote_addr", '
'"remote_port": "$remote_port", '
'"upstream_addr":"$upstream_addr", '
'"bytes_sent": "$bytes_sent", '
'"status": "$status" } }';
upstream sit {
server 10.224.206.13:1521 max_fails=30 fail_timeout=30s;
}
upstream uat {
server 10.224.206.14:1521 max_fails=30 fail_timeout=30s;
}
server {
listen 1522;
proxy_connect_timeout 6000s;
proxy_timeout 6000s;
proxy_pass sit;
}
server {
listen 1523;
proxy_connect_timeout 6000s;
proxy_timeout 6000s;
proxy_pass uat;
}
}
3.2 代理http
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
send_timeout 240;
keepalive_timeout 65;
fastcgi_buffers 8 128k;
client_max_body_size 1000M;
#support websocket
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 8080;
server_name localhost tzjy.fcsc.com;
location / {
root html;
index index.html index.htm;
}
location /web {
proxy_pass http://10.224.203.96:8081/web;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE_HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_read_timeout 3600s;
}
location /web/xcc_webSocket {
proxy_pass http://10.224.203.96:8081/web/xcc_webSocket;
proxy_read_timeout 3600s;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE_HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_redirect off;
}
location /xquant-xtps-startup-war-0.0.1 {
proxy_pass http://10.224.202.136:8091/xquant-xtps-startup-war-0.0.1;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE_HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_redirect off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
标签:set,http,timeout,header,Nginx,proxy,nginx,转发 来源: https://www.cnblogs.com/joesenno1/p/16426940.html