Nginx转发
2022/7/1 5:19:37
本文主要是介绍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; } } }
这篇关于Nginx转发的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-29Nginx发布学习:从入门到实践的简单教程
- 2024-10-28Nginx发布:新手入门教程
- 2024-10-21nginx 怎么设置文件上传最大20M限制-icode9专业技术文章分享
- 2024-10-17关闭 nginx的命令是什么?-icode9专业技术文章分享
- 2024-09-17Nginx实用篇:实现负载均衡、限流与动静分离
- 2024-08-21宝塔nginx新增8022端口方法步骤-icode9专业技术文章分享
- 2024-08-21nginx配置,让ws升级为wss访问的方法步骤-icode9专业技术文章分享
- 2024-08-15nginx ws代理配置方法步骤-icode9专业技术文章分享
- 2024-08-14nginx 让访问带有/relid的地址返回404 ,例子 /relid-x-0.36-y-131.html-icode9专业技术文章分享
- 2024-08-14nginx 判断地址有/statics/的路径,指向到/home/html/statics/目录-icode9专业技术文章分享