社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  NGINX

如何在nginx中配置子域以指向同一tomcat主机中的specefic html文件

user3600935 • 5 年前 • 390 次点击  

我在tomcat上有一个网站,如www.mysite.com:2121和nginx point(作为代理),如下所示:

mysite.com=>www.mysite.com:2121

www.mysite.com=>www.mysite.com:2121

我想创建一个子域,如ui.mysite.com,指向mysite.com:8080/index_ui.html,如下所示:

ui.mysite.com=>mysite.com:8080/index_ui.html

我在nginx.conf中尝试:

  server {
    listen          80;
    server_name     mysite.com www.mysite.com; 

    location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass htt://www.mysite.com:2121;
    }
  }
server {
    listen          80;
    server_name     ui.mysite.com ; 
    location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass htt://www.mysite.com:2121/index_ui.html;
    }
  }

此代码仅适用于HTML,不适用于CSS和JS,因为这些文件位于同一主机中,浏览器在其中查找它们

ui.mysite.com/css(诺基亚)

而不是

mysite.com/css(确定)

我也使用此配置,这意味着重定向所有exept index_ui.html:

rewrite ^(?!^(/index_ui.html)$)/.*$htt://www.xrdini.com/$1 permanent;

这项工作更好,但在不好,因为它不利于搜索引擎优化,它使用户重定向到 mysite.com/index_ui.html 不是 ui.mysite.com/index_ui.html

如何配置Nginx和/或Tomcat?

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/52013
 
390 次点击  
文章 [ 1 ]  |  最新文章 5 年前