Nginx转发解析长域名多路径域名.240105

​Nginx解析短域名,例如:访问 http://192.168.1.23 可直接跳转到 http://192.168.1.23/webroot/decision

server {
listen 90;
server_name localhost;
#匹配/ 转到/webroot/decision上;
#^(.*)$表示/后任意部分,除非和其他location匹配否则一律转向/webroot/decision,如果无需这样可以修改这里location或者rewrite的正则;
#permanent表示重定向并返回301;
location / {
rewrite ^(.*)$ /webroot/decision permanent;
}
location /webroot {
proxy_pass http://crm;
......
}
}

实际案例:

server{
listen 443 ssl;
server_name ***.***.cn;
ssl_certificate ssl/server.crt;
ssl_certificate_key ssl/server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
location / {
rewrite ^(.*)$ /webroot/decision permanent;
}
location /webroot {
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://xxx.xxx.xxx.xxx:8080;
}
}
posted @   中国的Amadeus  阅读(11)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示