0

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:

This is what I have so far:

<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>

Everything seems to work as expected for it.mysite.com

However, if I go to as.mysite.com, I get: https://it.mysite.com/servicedesk/customer/portal/2

Https redirect works, the correct portal (2) is shown, but, the domain reverts to it.mysite.com

The same happens for any page I visit. For example: - 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?

Wesley Smith
  • 101
  • 6
  • Although syntactically valid, using hostnames in tags is a bad idea. User *:port it IP:port (and dont mix the two unless you know what you are doing. I'd start by examining the output of "apachectl -S" and look for conflicting ServerNames/ServerAliases – Unbeliever Aug 23 '16 at 10:11
  • @Unbeliever, I changed all the vhosts to be `*:port`. Im on windows, but I ran `httpd -k stop` then `httpd -k start`, no warnings displayed and no errors in the log but the issue persits. – Wesley Smith Aug 23 '16 at 10:32
  • DelightedD0D, can you show the output of "httpd -S" please? – Unbeliever Aug 23 '16 at 10:56

1 Answers1

0

Your vhosts look fine. I would do the following to troubleshoot

1) Before each test, explicitly clear your browser cache, or use a command line tool such as curl to test the request

2) Add vhost specific access/error logs to each virtual host to make sure that the requests you are making are landing on the correct vhost

3) Enable the mod_rewrite logging to debug the rewrite. Details can be found here: http://wiki.apache.org/httpd/RewriteLog

Unbeliever
  • 2,336
  • 1
  • 10
  • 19