Window
到C:\Windows\System32\drivers\etc\目录下修改hosts文件,加入你要映射的域名如下:
127.0.0.1 dpa.xxx.com
127.0.0.1 dcas.xxx.com
配置conf下的nginx.conf文件
那我们就写个域名和端口的对应关系如下:
localhost 8088
dpa.xxx.com 8080
dcas.xxx.com 8090
具体的配置如下:
server {
listen 80;
server_name dcas.xxx.com;
location / {
proxy_passhttp://127.0.0.1:8090/;
}
}
server{
listen 80;
server_name dpa.xxx.com;
location / {
proxy_passhttp://127.0.0.1:8080/;
}
}
server{
listen 80;
server_name localhost;
location / {
proxy_passhttp://127.0.0.1:8088/;
}
}
Linux
添加
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;
#}
}
内容源来自:https://blog.csdn.net/jingmo55/article/details/70801084/