开发者社区> 问答> 正文

nginx 转发到 tomcat 的 ServerName 配置问题,求助。

nginx配置是这样的:
`......
location / {

    proxy_pass http://localhost:8080;
    include proxy.conf;
}

......`
Jsp 中要用到 request.getServerName(), 但现在这样配置获得的内容总是 "localhost"
我想要获得用户访问时用到的域名.
比如: terry.oschina.net
我是第一次使用nginx, 谁碰到过这个情况的,请教一下,先谢谢了!

展开
收起
落地花开啦 2016-03-24 18:15:06 3910 0
1 条回答
写回答
取消 提交回答
  • 喜欢技术,喜欢努力的人

    proxy.conf 怎么写的,一定要有 proxy_set_header Host $host;
    `location / {

        proxy_pass http://localhost:8080;
       proxy_set_header Host $host;
    }`
    2019-07-17 19:13:13
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载