Use hostname for alias function not working

Aedero

Verified User
Joined
Sep 28, 2013
Messages
20
Hello,

When I use the following settings in options.conf for my server:

Code:
use_hostname_for_alias=yes
redirect_host=s1.aedero.net
redirect_host_https=yes

The redirect does not work, even after I tried to do:
Code:
./build rewrite_confs

Everytime I try to open the page I get a page 404 Not Found error.

Can somebody please help me?

With kind regards,

Robin
 
Yes, I can confirm this bug in custombuild 2.0. I have reported it in the forum before, but it seems they have not understood my report, because it is not fixed yet.

You can see that phpmyadmin without capital letters does not work:
yourserver.hostname.com/phpmyadmin/

But if you use capital letters like this, then it works:
yourserver.hostname.com/phpMyAdmin/

To fix the problem, you can edit /etc/httpd/conf/extra/httpd-alias.conf and add these two lines at the bottom of the file:

Code:
Alias /roundcube /var/www/html/roundcube/
Alias /phpmyadmin /var/www/html/phpMyAdmin/

After you have added those line, you must restart apache:
Code:
servicec httpd restart
 
Last edited:
Hello,

Thanks for the report.
Can you dump us your config?
Code:
./build options
and maybe the contents of your httpd-aliases.conf.

Make sure you're using the latest CB2 script as well, eg:
Code:
./build update
./build rewrite_confs
I'm testing on a CentOS 5 box, CB 2 with php1_mode=fastcgi, seems to be working.

John
 
I have the same problem on all my 4 servers. All running CentOS 6.4 64bit, Apache 2.4.6, PHP 5.4.21 and mod_ruid2. Also it is only a few weeks ago I did rewrite_confs. Here is my options.conf:

Code:
#PHP settings.
#Default version of PHP is always php1_release. Possible values for php1/php2_release: 5.3, 5.4, 5.5, no. php1/php2_mode: mod_php, fastcgi, php-fpm or suphp)
php1_release=5.4
php2_release=no
php1_mode=mod_php
php2_mode=php-fpm
php_ini=yes
php_timezone=Europe/Oslo
#Possible values - production or development
php_ini_type=production
ioncube=yes
zend=no

#HTTP server. Possible values: apache, nginx
webserver=apache

#Apache settings
#Possible value: 2.4
apache_ver=2.4
mod_ruid2=yes
secure_htaccess=no
harden-symlinks-patch=yes
use_hostname_for_alias=yes
redirect_host=xxxx.xxxx.xxx
redirect_host_https=yes

#Possible values - 5.1, 5.5, 5.6
mysql=5.6
mysql_inst=yes
mysql_backup=yes
mysql_backup_dir=/home/admin/dbup_backups

#Web applications
phpmyadmin=yes
squirrelmail=no
roundcube=yes

#Mail options
exim=yes
eximconf=yes
clamav=yes
spamassassin=yes
dovecot=yes
pigeonhole=no

#Statistics
awstats=yes
webalizer=no

#FTP options - possible values: proftpd, pureftpd
ftpd=proftpd

#Jailed shell
jail=no

#Autoconf/automake/libtool options
autoconf=yes
automake=yes
libtool=yes
curl=yes

#new version of zlib and libxml2 (experts only)
zlib=no
new_zlib=no
new_xml2=yes
new_pcre=yes

#Custombuild options
custombuild=2.0
autover=no
bold=no
clean=yes
cleanapache=no
clean_old_tarballs=no
clean_old_webapps=no
downloadserver=files1.directadmin.com

#Cron settings
cron=no
cron_frequency=daily
[email protected]
notifications=yes
da_autoupdate=no
updates=no
webapps_updates=no

#Cloudlinux settings
cloudlinux=no
cagefs=no
old_apr_util=no
phpmyadmin_ver=4
htscanner=no
x-mail-header=yes
new_suphp=no

Here is my httpd-alias.conf with my extra lines at the bottom to fix the problem:

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^xxxx.xxxx.xxx$
RewriteCond %{REQUEST_URI} ^/config/ [OR]
RewriteCond %{REQUEST_URI} ^/config$ [OR]
RewriteRule ^/config(.*) https://xxxx.xxxx.xxx/redirect.php$1

RewriteCond %{HTTP_HOST} !^xxxx.xxxx.xxx$
RewriteCond %{REQUEST_URI} ^/roundcube/ [OR]
RewriteCond %{REQUEST_URI} ^/roundcube$ [OR]
RewriteRule ^/roundcube(.*) https://xxxx.xxxx.xxx/roundcube$1

RewriteCond %{HTTP_HOST} !^xxxx.xxxx.xxx$
RewriteCond %{REQUEST_URI} ^/webmail/ [OR]
RewriteCond %{REQUEST_URI} ^/webmail$ [OR]
RewriteRule ^/webmail(.*) https://xxxx.xxxx.xxx/roundcube$1

RewriteCond %{HTTP_HOST} !^xxxx.xxxx.xxx$
RewriteCond %{REQUEST_URI} ^/phpMyAdmin/ [OR]
RewriteCond %{REQUEST_URI} ^/phpMyAdmin$ [OR]
RewriteRule ^/phpMyAdmin(.*) https://xxxx.xxxx.xxx/phpMyAdmin$1

RewriteCond %{HTTP_HOST} !^xxxx.xxxx.xxx$
RewriteCond %{REQUEST_URI} ^/phpmyadmin/ [OR]
RewriteCond %{REQUEST_URI} ^/phpmyadmin$ [OR]
RewriteRule ^/phpmyadmin(.*) https://xxxx.xxxx.xxx/phpMyAdmin$1

RewriteCond %{HTTP_HOST} !^xxxx.xxxx.xxx$
RewriteCond %{REQUEST_URI} ^/pma/ [OR]
RewriteCond %{REQUEST_URI} ^/pma$ [OR]
RewriteRule ^/pma(.*) https://xxxx.xxxx.xxx/phpMyAdmin$1

Alias /roundcube /var/www/html/roundcube/
Alias /phpmyadmin /var/www/html/phpMyAdmin/

I will try to find my old forum post about it too, and post the link when I find it.
 
Last edited:
I've figured it out.
The fastcgi setup adds these to each domain's VH:
Code:
RewriteEngine on
RewriteOptions inherit
The "inherit" is what's missing in the mod_php/ruid setup.

We'll have to look at adding it by default.. if it's "correct" to do so. (perhaps only if the hostname alias option is used)

John
 
Hi John,

Thank you for the solution I'm going to apply it tommorow!

With kind regards,

Robin
 
Hi John,

Thank you! The solution works.
Can you tell me maybe when this will be included in Custombuild?

With kind regards,

Robin
 
Hi,

Can someone please fix this code in Custombuild?
Then I can install our servers automaticly without adjusting manual files.

With kind regards,
Robin
 
Could we get this fixed for PHP-FPM as well please?

options.conf
Code:
use_hostname_for_alias=yes
redirect_host=my.domain.com
redirect_host_https=yes

That only creates aliases FOR USERS
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my.domain.com$
RewriteCond %{REQUEST_URI} ^/config/ [OR]
RewriteCond %{REQUEST_URI} ^/config$ [OR]
RewriteRule ^/config(.*) https://my.domain.com/redirect.php$1

RewriteCond %{HTTP_HOST} !^my.domain.com$
RewriteCond %{REQUEST_URI} ^/webmail/ [OR]
RewriteCond %{REQUEST_URI} ^/webmail$ [OR]
RewriteRule ^/webmail(.*) https://my.domain.com/webmail$1

The first block will never work until php is enabled again for /var/www/html, but the 2nd one doesn't work either. Users get a 404.

The new template as described here will never add anything to the vhost of users using PHP-FPM.
Result of the conditional tests:
Code:
ADD_REWRITE_INHERIT=no
ADD_CLI_INHERIT=no

What does kind of work FOR USERS when using PHP-FPM is this:
Code:
Alias /webmail3 /var/www/html/webmail/
but that's bad because the final URL will always raise alerts and fail in some browsers when using HTTPS because the domain won't match the certificate.

Something which works FOR USERS when using PHP-FPM is adding this to their /home directory directive:
Code:
Redirect /webmail https://my.domain.com/webmail/
They always land on a URL which works and gives no warning.

Server aliases
Now the problem is that aliases don't work at the server root, so something like this:
Code:
Alias /phpmyadmin /var/www/html/phpMyAdmin/
Always gives us a 404 when visiting
https://my.domain.com/phpmyadmin
 
Last edited:
Back
Top