Accessing site via multiple virtual hosts with https

I have an apache server that sits in front of a JIRA Service Desk instance running on Windows Server 2012.

We have 2 customer portals in JIRA and I need to set up Apache so that each customer portal can be accessed via a different virtual host.

Like this:

Вот что у меня есть:

<VirtualHost *:80>
RewriteEngine on
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
RewriteRule ^/$ /servicedesk/customer/portal/1/ [R=301]
DocumentRoot "c:/Apache24/htdocs"
#Redirect permanent / https://www.it.mysite.com/  # tried this, it seemed to be ignored
ServerName www.it.mysite.com
ServerAlias it.mysite.com
....
</VirtualHost>


<VirtualHost *:80>
RewriteEngine on
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
RewriteRule ^/$ /servicedesk/customer/portal/2/ [R=301]
DocumentRoot "c:/Apache24/htdocs"
#Redirect permanent / https://www.as.mysite.com/  # tried this, it seemed to be ignored
ServerName www.as.mysite.com
ServerAlias as.mysite.com
....
</VirtualHost>



<VirtualHost *:443>
RewriteEngine on
RewriteRule ^/$ /servicedesk/customer/portal/1 [R=301] 
RewriteRule ^/servicedesk/customer/portals$ https://it.mysite.com/servicedesk/customer/portal/1 [R=301] 
DocumentRoot "c:/Apache24/htdocs"
ServerName www.it.mysite.com
ServerAlias it.mysite.com
...
</VirtualHost>



<VirtualHost *:443>
RewriteEngine on
RewriteRule ^/$ /servicedesk/customer/portal/2 [R=301] 
RewriteRule ^/servicedesk/customer/portals$ https://as.mysite.com/servicedesk/customer/portal/2 [R=301] 
DocumentRoot "c:/Apache24/htdocs"
ServerName www.as.mysite.com
ServerAlias as.mysite.com
...
</VirtualHost>

Кажется, все работает для it.mysite.com

Однако, если я захожу на as.mysite.com, я получаю: https://it.mysite.com/servicedesk/customer/portal/2

Перенаправление HTTP работает, отображается правильный портал (2), но домен возвращается к it.mysite.com

То же самое происходит с любой страницей, которую я посещаю. Например: - as.mysite.com/somepage.html gets me https://as.mysite.com/somepage.html

Output for C:\apache24\bin\httpd -S is:

VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server www.it.mysite.com (C:/Apache24/conf/httpd.conf:541)
         port 80 namevhost www.it.mysite.com (C:/Apache24/conf/httpd.conf:541)
                 alias it.mysite.com
         port 80 namevhost www.as.mysite.com (C:/Apache24/conf/httpd.conf:562)
                 alias as.mysite.com
*:443                  is a NameVirtualHost
         default server www.it.mysite.com (C:/Apache24/conf/httpd.conf:596)
         port 443 namevhost www.it.mysite.com (C:/Apache24/conf/httpd.conf:596)
                 alias it.mysite.com
         port 443 namevhost www.as.mysite.com (C:/Apache24/conf/httpd.conf:636)
                 alias as.mysite.com
ServerRoot: "C:/Apache24"
Main DocumentRoot: "C:/Apache24/htdocs"
Main ErrorLog: "C:/Apache24/logs/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="C:/Apache24/logs/" mechanism=default
PidFile: "C:/Apache24/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG

C:\Windows\system32>

How can I make it keep the as subdomain?

0
задан 23 August 2016 в 14:50
1 ответ

Ваши хосты выглядят нормально. Я бы сделал следующее для устранения неполадок

1) Перед каждым тестом явно очищайте кеш браузера или используйте инструмент командной строки, такой как curl, для проверки запроса

2) Добавьте журналы доступа / ошибок для каждого виртуального хоста host, чтобы убедиться, что запросы, которые вы делаете, попадают на правильный vhost

3) Включите ведение журнала mod_rewrite для отладки перезаписи. Подробности можно найти здесь: http://wiki.apache.org/httpd/RewriteLog

0
ответ дан 5 December 2019 в 09:40

Теги

Похожие вопросы