nginx日常配置总结
2020-07-14 06:15
363 查看
记录日常运维,文章会持续更新。。
域名解析相关
要求如下:https访问test.iris.com,加/api/访问后端应用,并且反代到两台机器,并且其中一台是本地机器,另外一台是通过阿里云SLB访问(uat.iris.com)。
配置如下:
upstream iris-test { server uat.iris.com:80 weight=1 max_fails=2 fail_timeout=10s; server 10.10.110.40:4328 weight=1 max_fails=2 fail_timeout=10s; } server { listen 80; server_name test.iris.com; rewrite ^(.*)$ https://${server_name}$1 permanent; } server { listen 443 ssl; server_name test.iris.com; ssl_certificate key/iris.com.pem; ssl_certificate_key key/iris.com.key; access_log logs/iris-test-access.log main; error_log logs/iris-test-error.log error; location / { proxy_pass http://10.10.110.122:4014; # include proxy.conf; } location ^~ /api/ { rewrite ^/api(.*)$ $1 break; #这里把/api去掉 proxy_set_header Host 'uat.iris.com';#这里踩坑踩好久呀,最后找大佬解决的,不能用“$host” proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://iris-test; #这里后面可能不能加‘/’,要用rewrite过滤 } #这里是配置静态页面,把txt文件放入html目录下即可 location ~ .*\.(txt)$ { expires 24h; root html; proxy_store on; proxy_temp_path html; proxy_redirect off; proxy_set_header Host 127.0.0.1; client_max_body_size 10m; client_body_buffer_size 1280k; proxy_connect_timeout 900; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 40k; proxy_buffers 40 320k; proxy_busy_buffers_size 640k; proxy_temp_file_write_size 640k; } }
相关文章推荐
- 【转】nginx配置location总结及rewrite规则写法
- Nginx 常用配置总结(root , alias,rewrite , proxy_pass ,if和内置变量,upstream 的使用)
- (总结)Nginx配置文件nginx.conf中文详解
- Nginx总结(五)如何配置nginx和tomcat实现反向代理
- (总结)Nginx配置文件nginx.conf中文详解
- 死磕 Nginx 系列:Nginx 限流配置,总结Nginx实战核心知识
- (总结)Nginx配置文件nginx.conf中文详解
- (总结)Nginx配置文件nginx.conf中文详解
- Nginx配置location总结及rewrite规则写法
- Nginx配置文件指令简单总结之一
- 日常总结(十一)maven配置环境变量提示:mvn不是内部或外部命令,也不是可运行的程序或批处理文件
- 关于nginx配置的不完全总结
- (总结)Nginx与Apache、Tomcat、Resin动静分离核心配置
- (总结)Nginx与Apache、Tomcat、Resin动静分离核心配置
- (总结)Nginx配置文件nginx.conf中文详解
- nginx配置location总结及rewrite规则写法
- (总结)Nginx配置文件nginx.conf中文详解
- nginx配置location总结及rewrite规则写法
- nginx配置location总结及rewrite规则写法
- (总结)Nginx与Apache、Tomcat、Resin动静分离核心配置