доступ к нескольким веб-сайтам, которые размещены на одном сервере через имя DNS - PullRequest
0 голосов
/ 14 октября 2019

Я развернул два приложения в Apache / Tomcat), которые работают следующим образом (http://xx.xx.xx.xx:8080/castag/, http://xx.xx.xx.xx:8080/filltag/), и я могу получить доступ как без проблем

, но мое требование,

http://xx.xx.xx.xx:8080/castag/ ------> casstag.abc.com

http://xx.xx.xx.xx:8080/filltag/ -----> filltag.abc.com

для этого,

1.добавить две записи узла А на DNS-сервере

2. Я установил сервер nginx и внесу некоторые изменения в server.xml на сервере Apache Tomcat

   <Context path="/casstag" docBase="/opt/apache-tomcat-6.0.45/webapps/casstag" debug="0"
                reloadable="true" cachingAllowed="false"
                allowLinking="true" />
   <Context path="/filltag" docBase="/opt/apache-tomcat-6.0.45/webapps/filltag" debug="0"
                reloadable="true" cachingAllowed="false"
                allowLinking="true" />

создайте два файла conf (castag.conf и filltag.conf) в nginx / etc / nginx / sites-enabled /
server {
    listen xx.xx.xx.xx:80;
    server_name def.abc.com ;

    root /opt/apache-tomcat-6.0.45/webapps;

        location / {
                deny all;
        }

    location /castag/ {
        index index.jsp;
        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 http://xx.xx.xx.xx:8080/castag/; 
        proxy_redirect  http://xx.xx.xx.xx:8080/castag/  http://casstag.abc.com ;

        proxy_buffering off;
        proxy_store     off;

        proxy_connect_timeout 120;
        proxy_send_timeout    120;
        proxy_read_timeout    120;

    }
}

server {

    listen xx.xx.xx.xx:80;
    server_name def.abc.com ;

    root /opt/apache-tomcat-6.0.45/webapps;

        location / {
                deny all;
        }
 location /filltag/ {
        index index.jsp;
        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 http://xx.xx.xx.xx:8080/filltag/; 
        proxy_redirect  http://xx.xx.xx.xx:8080/filltag/  filltag.abc.com ;

        proxy_buffering off;
        proxy_store     off;

        proxy_connect_timeout 120;
        proxy_send_timeout    120;
        proxy_read_timeout    120;
    }
}



1 Ответ

0 голосов
/ 14 октября 2019

Согласно nginx.org docs вы должны установить server_name для каждого сервера. Затем вы должны создать несколько серверов с разными корневыми каталогами.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...