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; } }
喜欢请赞赏一下啦^_^

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?