nginx反向代理:两个域名指向不同web服务端口
一台服务器上安装了zabbix服务和jumpserver服务,两个域名zabbix.xxxx.xxxx和jumserver.xxx.xxxx
一、编辑/etc/nginx/conf.d目录下nginx.conf
添加
include /etc/nginx/conf.d/*.conf;
二、在/etc/nginx/conf.d目录下新建zabbix.conf文件
server {
listen 80; //监听80
server_name zabbix.xxxx.com; //设置访问的域名
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /var/www/zabbix; //zabbix web的根目录
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /var/www/zabbix;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/zabbix$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
三、在/etc/nginx/conf.d目录下新建jumpserver.conf文件
server {
listen 80; //监听80
server_name jumpserver.xxxx.com; //设置访问的域名
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location /static/{
root /usr/local/jumpserver/data/;
}
location /luna/ {
try_files $uri / /index.html;
alias /usr/local/luna/; # luna 路径, 如果修改安装目录, 此处需要修改
}
location /media/ {
add_header Content-Encoding gzip;
root /usr/local/jumpserver/data/; # 录像位置, 如果修改安装目录, 此处需要修改
}
location /socket.io/ {
proxy_pass http://localhost:5000/socket.io/; # 如果coco安装在别的服务器, 请填写它的ip
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location /coco/ {
proxy_pass http://localhost:5000/coco/; # 如果coco安装在别的服务器, 请填写它的ip
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location /guacamole/ {
proxy_pass http://localhost:8081/; # 如果guacamole安装在别的服务器, 请填写它的ip
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
access_log off;
}
location / {
proxy_pass http://localhost:8080/; //访问域名指向这个ip的端口web服务(反向代理)
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
# location ~ \.php$ {
# root /var/www/;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
四、重启nginx服务
service nginx reload
五、验证
浏览器打开:http://jumpserver.xxx.com

浏览器打开:http://zabbix.xxxx.com

nginx反向代理:两个域名指向不同web服务端口的更多相关文章
- 002-nginx-在 nginx 反向代理中使用域名,配置动态域名解析
一.概述 代理(proxy),即中间人,它代替客户端发送请求给服务器,收到响应后再转给客户端.通常意义上的代理是从用户的角度讲的,用户通过某个代理可以访问多个网站,这个代理是靠近用户的,比如某些公司可 ...
- Nginx反向代理两个tomcat服务器
第一步,在Linux上安装两个tomcat,修改好端口号后,启动起来. 第二步,配置本地的DNS解析,即修改host文件: 第三步,配置Nginx配置文件 反向代理的配置虚拟主机配置差不多也要配置虚拟 ...
- EG:nginx反向代理两台web服务器,实现负载均衡 所有的web服务共享一台nfs的存储
step1: 三台web服务器环境配置:iptables -F; setenforce 0 关闭防火墙:关闭setlinux step2:三台web服务器 装软件 step3: 主机修改配置文件:vi ...
- Nginx 反向代理(http转htpps,并支持80端口继续提交post请求)
项目是一个web server + 多个client的形式,client由用户安装在自己的电脑上 由http升级为https后,我们通过在Nginx做了80端口重定向443的配置,使用户通过访问htt ...
- tomcat+nginx反向代理(实现一个服务器,一个ip共用80端口)
http://blog.csdn.net/sinat_33388558/article/details/54837051 http://www.cnblogs.com/zhouqinxiong/p/5 ...
- JAVAEE——宜立方商城03:商品类目选择、Nginx端口或域名区分虚拟机、Nginx反向代理、负载均衡、keepalived实现高可用
1. 学习计划 第三天: 1.商品类目选择(EasyUI的tree实现) 2.图片上传 a) 图片服务器FastDFS(Nainx部分) 2. 商品类目选择 2.1. 原型 2.2. 功能分析 展示商 ...
- 搭建nginx反向代理用做内网域名转发
先上一个我的正常使用的配置 location / { proxy_pass http://192.168.1.84:80; proxy_redirect off; proxy_set_header H ...
- 把www.domain.com均衡到本机不同的端口 反向代理 隐藏端口 Nginx做非80端口转发 搭建nginx反向代理用做内网域名转发 location 规则
负载均衡-Nginx中文文档 http://www.nginx.cn/doc/example/loadbanlance.html 负载均衡 一个简单的负载均衡的示例,把www.domain.com均衡 ...
- 端口被占用通过域名的处理 把www.domain.com均衡到本机不同的端口 反向代理 隐藏端口 Nginx做非80端口转发 搭建nginx反向代理用做内网域名转发 location 规则
负载均衡-Nginx中文文档 http://www.nginx.cn/doc/example/loadbanlance.html 负载均衡 一个简单的负载均衡的示例,把www.domain.com均衡 ...
随机推荐
- uiautomator 代码记录 : BT发送测试
package rom; import java.lang.*; import java.util.Random; import java.io.File; import com.android.ui ...
- FastDFS 配置 Nginx 模块,并实现分布式同步-Linux
1.搭建虚拟机 a.复制虚拟机文件 首先复制我们之前安装好的fastdfs虚拟机,因为我们现在要设置它的IP为21,改名为CentOS-fastdfs - 21. b.设置网络 生成新的MAC地址 设 ...
- 33.纯 CSS 创作牛奶文字变换效果
原文地址:https://segmentfault.com/a/1190000015037234 感想:transform: translateY(50% & -50%); animatio ...
- leetcode1012
# given number n, see whether n has repeated number def has_repeated(n): str_n = str(n) return len(s ...
- TFrame bug
delphi 10.1.2 工程里有很多fram 正确的工程文件dproj中fram的定义是 <DCCReference Include="Unit15frame.pas"& ...
- How to install Redis 3.2 on CentOS 6 and 7
What is Redis? Redis is a flexible open-source, key value data store, used as a database, cache and ...
- Ajax技术剖析
Ajax的全称是Asynchronous JavaScript and XML,是JS的特有功能,它作用是异步JS数据交互,即在不进行页面刷新的情况下进行部分数据的获取,性能较高.值得注意的是,仅有A ...
- Leetcode 题解 First Missing Positive
Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] ...
- Review CSS Selectors
Throughout this lesson, you learned how to select HTML elements with CSS and apply styles to them. L ...
- 优秀的 Go 存储开源项目和库
可以看到,今年谷歌家的 Go 编程语言流行度有着惊人的上升趋势,其发展也是越来越好,因此本文整理了一些优秀的 Go 存储相关开源项目和库,一起分享,一起学习. 存储服务器(Storage Server ...