Hi i setup my site site1 with an alias site2.
If I choose redirect to site2, I get the install.php for site2

I did this on my hostmaster setup and it completely broke it all.

Comments

anarcat’s picture

socialnicheguru’s picture

i do not have ssl enabled

m.stenta’s picture

@SocialNicheGuru: can you please post the chunk of your site's virtual host that begins with <IfModule mod_rewrite.c> and ends with </IfModule>.

It should contain a series of RewriteCond and RewriteRule statements. It will help a lot to see what you are ending up with.

The virtual host file is in /var/aegir/config/server_master/apache/vhost.d/

m.stenta’s picture

Some of the code in vhost.tpl.php looks funky to me. I don't know if it's related to this issue, but I thought I would point it out here as a start.

Attached is a patch.

The main things I changed:

  • Fixed condition when SSL redirection is enabled and an alias redirect is set. Previously it was redirecting to the default URI (not the selected alias).
  • Added an extra space to the beginning of each line to fix alignment of vhost rules.
  • Improved comments.

Also, I removed the setting of $data['redirect_url'] in both SSL and non-SSL vhosts, because it is not being used anywhere (I grepped the entire Provision directory, and didn't see it anywhere else). My guess is this was used in the past, but the code was refactored and it was orphaned. I might be wrong about that. Perhaps one of the core maintainers knows for sure.

I tested the following scenarios and they all work:

  • Site with an alias that is the default redirect (example.com (default URI) redirects to www.example.com (alias)). SSL is "Enabled" (not "Required").
  • Site with an alias that is the default redirect (example.com (default URI) redirects to www.example.com (alias)). SSL is "Required".
  • Site with an alias, no redirects. SSL "Required".
  • Site with an alias, no redirects. SSL "Enabled".
m.stenta’s picture

Again, it doesn't look like this patch will fix the issue described by SocialNicheGuru, so we'll need to wait to get a response from him with the content of his vhost before we can fix that. But combined with #2084963: SSL vhost does not respect Alias redirects, this patch should help to clean up some of the redirect logic a bit.

socialnicheguru’s picture

I was experimenting.
I have setup aegir within virtualbox ubuntu 12.04 guest
I was trying to get my host to be able to view the websites through a browser

config/server_master/apache/vhost.d/mytestservermaster.com

I added an alias

ServerAlias 192.168.1.15
ServerAlias mytestservermaster.com
ServerAlias 1mytestservermaster.com

<IfModule mod_rewrite.c>
  RewriteEngine on
 RewriteCond %{HTTP_HOST} !^1mytestservermaster.com$ [NC]
 RewriteRule ^/*(.*)$ http://1mytestservermaster.com/$1 [NE,L,R=301]
  RewriteRule ^/files/(.*)$ /sites/1mytestservermaster.com/files/$1 [L]
  RewriteCond /var/aegir/hostmaster-6.x-2.0-rc4/sites/1mytestservermaster.com/files/robots.txt -f
  RewriteRule ^/robots.txt /sites/1mytestservermaster.com/files/robots.txt [L]
</IfModule>
m.stenta’s picture

Did you add the aliases via the Aegir interface (this is the right way)? Or by editing the virtual host file manually?

You listed three aliases, but the middle one (mytestservermaster.com) is the same as the site's actual URI, isn't it? If so, that should not be an alias. It should be the ServerName (in the vhost).

You also said "I was trying to get my host to be able to view the websites through a browser" ... was it ever working? Did setting up the alias redirect break it? I'm confused.

Just want to make sure I understand how you got to where you are, and that everything is set up right.

anarcat’s picture

Status: Active » Needs work
+++ b/http/Provision/Config/Apache/vhost.tpl.phpundefined
@@ -32,17 +32,17 @@ if (sizeof($this->aliases)) {
-    // redirect aliases in non-ssl to the same alias on ssl.
-    print " RewriteRule ^/*(.*)$ https://%{HTTP_HOST}/$1 [NE,L,R=301]\n";
+    // Redirect aliases in non-SSL to the same alias on SSL.

please try to keep whitespace changes separate, from what i can tell, there is no actual change here...

anarcat’s picture

Priority: Normal » Critical

if this is not a dupe, then it's a critical.

chertzog’s picture

i cant reproduce.

Here was what i did:

  1. Install aegir 6.x-2.x
  2. Add drupal 7 platform
  3. Check "Use redirects instead of aliases by default" in site alias settings.
  4. Create drupal 7 minial site test1.aegir.local with aliases test2.aegir.local and test3.aegir.local
  5. Set "Redirect all domain aliases to:" test2.aegir.local.

After everything verifies, visiting test1. test2. or test3. all redirect to test2.aegir.local welcome page.

anarcat’s picture

Status: Needs work » Postponed (maintainer needs more info)

ok then we need more info here...

1. verify the site, and provide a log of the verify task
2. provide the complete virtual host config file (censoring out the passwords, of course)
3. provide details of the site configuration in the frontend (a screenshot or proper copy/paste of the "view" tab of the site should be good enough)
4. provide details of the DNS configuration of the server
5. provide the output of apache2ctl -S

we messed around quite a lot to make sure redirections work properly since we added code to change the target of redirections, I was surprised it was actually broken...

socialnicheguru’s picture

#7.

Did you add the aliases via the Aegir interface (this is the right way)? Or by editing the virtual host file manually?

- I added aliases through the interface

You listed three aliases, but the middle one (mytestservermaster.com) is the same as the site's actual URI, isn't it? If so, that should not be an alias. It should be the ServerName (in the vhost).

- my typo. remove "ServerAlias mytestservermaster.com"

You also said "I was trying to get my host to be able to view the websites through a browser" ... was it ever working? Did setting up the alias redirect break it? I'm confused.

I never got it working.
I tried bind first but could not get it to work. There is an issue filed.
Then I tried dnsmasq

Just want to make sure I understand how you got to where you are, and that everything is set up right.

I did try to do a redirect of the hostmaster site.

anarcat’s picture

m.stenta’s picture

@SocialNicheGuru: Are we talking about two different issues here?? On the one hand, this issue is about alias redirection not working... right? But on the other hand you're saying that you can't even visit your sites?? I'm confused. Are we talking about two separate issues in two separate Aegir installations? If so, let's keep them separate in this issue to avoid confusion.

The easiest way to access your sites in a Virtual Machine is to edit your /etc/hosts file (on Mac/Linux) and point the domain to your local IP address. Have you tried this?

Is that the issue? Please clarify. If you can't get to any of your sites at all, then this isn't an alias redirection issue...

socialnicheguru’s picture

No. The issue for me was that I enabled redirect on alias.

The alias function worked fine:
mytestsite.com is the original site
1mystestsite.com is the alias

I could goto either just fine.

Then I tried redirection.

If I went to mytestsite.com or 1mytestsite.com i would be directed to: 1mytestsite.com/install.php

In my case specificayly mytestsite was my hostmaster site.

Please note:
I added the info on dns because that was what I was doing prior to enabling the redirect. I do not know if it has any bearing. I think it doesn't but I added simply for completeness. I am sorry for muddying the waters. I hope my explanation helps a little bit.

m.stenta’s picture

Ok, thanks, that does clarify.

So it sounds like this might be an issue with adding alias redirection to the Hostmaster site itself, specifically.

Have you tried adding alias redirection to any other sites in the system (not the Hostmaster site)? That would help to isolate the issue to Hostmaster if those work.

socialnicheguru’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (works as designed)

I am no longer getting this issue when I upgraded to aegir 2.0

socialnicheguru’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (works as designed)

I am no longer getting this issue when I upgraded to aegir 2.0