proxy.conf编写
#这里的test.com要与proxy_pass http://test.com 一至!
upstream test.com {
ip_hash;
server 172.16.0.20:80;
server 172.16.0.30:80;
}
upstream html.com{
server 172.16.0.20:80;
}
server {
listen 80;
root /home/scort/www;
index index.html index.htm;
server_name test.com;
location / {
try_files $url $uri/ =404;
}
#配置Nginx动静分离,定义的静态页面直接从Nginx发布目录读取。
location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
{
#方式一:本地
# root /home/scort/data;
#expires定义用户浏览器缓存的时间为3天,如果静态页面不常更新,可以设置更长,这样可以节省带宽和缓解服务器的压力
# expires 3d;
# 方式二:远程代理
proxy_set_header Host $host; # 主机名,作用:优先使用它来匹配域名;如果没有这个参数,则使用 proxy_pass的值来作为域名!
proxy_set_header X-Real-IP $remote_addr; # 客户端IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://html.com;
}
#动态页面交给http://test.com,也即我们之前在nginx.conf定义的upstream test.com 均衡
location ~ .*\.(php|jsp|cgi)?$
{
proxy_set_header Host $host; # 主机名,作用:优先使用它来匹配域名;如果没有这个参数,则使用 proxy_pass的值来作为域名!
proxy_set_header X-Real-IP $remote_addr; # 客户端IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://test.com;
}
}
proxy.conf编写的更多相关文章
- nginx proxy文件编写总结
upstream.conf upstream api { server 192.168.10.10:8080; server 192.168.10.20:8080;} server{ listen 4 ...
- 红帽企业版RHEL7.1在研域工控板上,开机没有登陆窗口 -- 编写xorg.conf 简单三行解决Ubuntu分辩率不可调的问题
红帽企业版RHEL7.1在研域工控板上,开机没有登陆窗口 没有登陆窗口 的原因分析: 没有登陆窗口的原因是因为有多个屏幕在工作,其中一个就是build-in 屏幕(内置的虚拟屏幕)和外接的显示器,并且 ...
- Linux基础-shell脚本知识整理和脚本编写----------变量、运算符、流程控制、函数、计划任务(发送邮件)
I:知识整理:变量.运算符.流程控制.函数.计划任务 变量 系统变量:set:显示所有变量 env:环境变量 常用系统变量: path pwd lang home his ...
- shell脚本编写-自动部署及监控
1.编写脚本自动部署反向代理.web.nfs: I.部署nginx反向代理两个web服务,调度算法使用加权轮询 II.所有web服务使用共享存储nfs,保证所有web都对其有读写权限,保证数据一致性: ...
- nginx.conf 完整的集群配置
###############################nginx.conf 整配置############################### #user nobody; # user 主模 ...
- nginx日志格式定义和nginx.conf配置模板说明
在http的功能里添加log_format模块,内容如下: log_format main escape=json '{ "@timestamp": "$time_iso ...
- ng7 设置http proxy
看文档 proxy.conf.json { "/api": { "target": "http://localhost:5000", &qu ...
- nginx.conf 集群完整配置
###############################nginx.conf 集群完整配置############################### #user nobody; # user ...
- haproxy + nginx + proxy protocol 获得客户真实IP方法
公司网站架构为: 前面2台HA负载均衡,后面3台Nginx负载均衡反向代理,然后后面有N台WEB服务器 由于要统计IP,需要在WEB服务器日志里体现客户端真实IP 那么问题来了,通过HA代理的HTTP ...
随机推荐
- centos yum install nginx
nginx newshttp://nginx.org/ nginx news: 2017http://nginx.org/2017.html nginx: Linux packageshttps:// ...
- centos yum install oracle java
How to install Java on CentOS 7 | Linuxizehttps://linuxize.com/post/install-java-on-centos-7/ CentOS ...
- 解决jenkins运行磁盘满的问题
解决jenkins运行磁盘满的问题 - ling811的专栏 - CSDN博客 https://blog.csdn.net/ling811/article/details/74991899 1.自动丢 ...
- IdentityServer4【Introduction】之包和项目构建
包和项目构建 IdentityServer包含了以下的nuget包: IdentityServer4 nuget | github 这个包包含了IdentityServer核心的组成部分,有对象模型, ...
- hangfire使用笔记
1.导入nuget包 2.配置 简单配置后就可以写自己的Job了 注意:Hangfire.RecurringJobExtensions这个扩展支持两种job添加方法:json配置文件和特性.但由于时区 ...
- MyEclipse 10.X激活方法
普遍的激活办法请参考: http://blog.csdn.net/miss_kun/article/details/51819206 http://jingyan.baidu.com/article/ ...
- [转帖]震惊,用了这么多年的 CPU 利用率,其实是错的
震惊,用了这么多年的 CPU 利用率,其实是错的 2018年12月22日 08:43:09 Linuxer_ 阅读数:50 https://blog.csdn.net/juS3Ve/article/d ...
- CIFS 与 SMB 有什么区别?
CIFS 与 SMB 有什么区别? https://www.getnas.com/2018/11/30/cifs-vs-smb/ 网络协议 一知半解 学习一下挺好的.. 记得 win2019 已经废弃 ...
- mysql 数据库的主从同步
1.复制准备 操作系统 centOS 主库(mysql master): ip为123.56.94.1 port为3306 mysql 版本 5.7.16 从库(mysql slave): ...
- 根据request获取请求客户端的外网ip
//根据request获取外网ip private static String getRemoteIp(HttpServletRequest request) { //x-forwarded-for: ...