大家好,又见面了,我是你们的朋友全栈君。
1,先贴配置内容
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream cms{
server 127.0.0.1:8081;
}
upstream bus{
server 127.0.0.1:8082;
}
server {
listen 80;
server_name localhost;
location /cms {
index index;
proxy_pass http://cms ;
}
location /bus {
index index;
proxy_pass http://bus ;
}
location =/ {
rewrite / /cms;
}
}
2,以上配置分为两部分:
第一部分,upstream +项目文件夹名称 +{ 127.0.0.1+端口}
第二部分,location /路径 {}
3,默认跳转地址配置:
location =/ {
rewrite / /cms;
}
rewrite是重写的意思,比如上面的配置结果是:输入192.168.3.30会跳转到192.168.3.30/cms
4,默认跳转的另一种配置方法,直接跳转到指定文件夹的html文件
location / {
index login.html;
root /usr/local/FengShen/web;
# proxy_pass http://127.0.0.1/web;
}
5,配置多个不同的项目的方法:server{}多复制几份就可以了。
server {
listen 80;
server_name xxxx.com;
index index.html index.htm;
root /opt/zletc;
}
server {
listen 80;
server_name www.xxxxx.com;
index index.html index.htm;
root /opt/zletc;
}
server {
listen 80;
server_name xxxx.yyyyyy.com;
index index.html index.htm;
root /opt/zletc;
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/196212.html原文链接:https://javaforall.cn