nginx反向代理
2018-08-17 09:31:55来源:博客园 阅读 ()
一、nginx.conf结构 events{} #nginx性能 stream{ upstream{ } server{ location{ } } } #四层转发 http{ upstream{ } server{ location{ } } } #七层转发 http { include /usr/local/nginx/conf.d/*.conf; #调用/usr/local/nginx/conf.d/下的配置文件 } 二三使用的upstream模块 upstream tomcat { server X.X.X.X:443 weight=100; } upstream raptor_tomcat { server X.X.X.X:8081 weight=100; } 二、server http代理http server { listen 18001; access_log /var/log/nginx/bl_http.log ngx_accss_json; location /status { stub_status on; access_log off; allow 127.0.0.1; allow 10.0.17.27; allow 10.0.1.142; deny all; } location / { proxy_http_version 1.1; proxy_set_header Connection ""; proxy_pass http://bl_tomcat; #Proxy Settings proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $http_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_ignore_client_abort on; proxy_max_temp_file_size 0; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } } #####http代理https 如果代理的后端是https服务,需要把黄色的代码改为https://bl_tomcat; 三、server https代理https server { listen 8443 ssl; server_name *.intellicredit.cn; root html; ssl on; ssl_certificate /usr/local/nginx/certs/intellicre.crt; ssl_certificate_key /usr/local/nginx/certs/intellicredit.cn.key; ssl_session_cache shared:SSL:20m; ssl_session_timeout 20m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; access_log /var/log/nginx/bl_https.log; location / { proxy_http_version 1.1; proxy_set_header Connection ""; proxy_pass https://tomcat; #Proxy Settings proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_max_temp_file_size 0; proxy_ignore_client_abort on; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffer_size 4k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; } } ##### 如果代理的后端是http服务,需要把黄色的代码改为http://tomcat; 四、四层TCP代理TCP,使用stream模块,nginx -V查看是否支持stream模块 stream { upstream test { hash $remote_addr consistent; server 1.1.1.1:80 weight=100; } server { listen 8080; proxy_connect_timeout 5s; proxy_timeout 5s; proxy_pass test; } }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
下一篇:NFS搭建
- 附020.Nginx-ingress部署及使用 2020-06-02
- Nginx + Docker 多阶段构建的部署学习 2020-05-25
- 万字长文!一次性弄懂 Nginx 处理 HTTP 请求的 11 个阶段 2020-05-21
- 关于Nginx处理HTTP请求的11个阶段流程 2020-05-07
- Nginx模块-ngx_http_ssl_module 2020-05-06
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash