PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Apache2 2.4.10 - Kein Rewrite möglich



Wambui
07.12.15, 10:47
Hallo,

ich habe seit dem Upgrade von Apache 2.2 auf Apache 2.4 meine Probleme mit dem Rewrite von URLs. Ich habe hier zwei virtuelle Server "www.ersatzdomain.com" und "www.ersatzdomain.eu" (Aus datenschutzrechtlichen Gründen nur diese Fantasienamen). Wobei der Aufruf von www.ersatzdomain.eu im Browser auf www.ersatzdomain.com forwarden soll. Bzw. zeigen die Configs ja auch, dass letztendlich auf "https://www.ersatzdomain.com" rewrited werden soll.
Das hatte bisher unter Apache 2.2 ganz prima funktioniert.

<VirtualHost 192.168.1.7:80>
ServerAdmin hostmaster@ersatzdomain.eu
DocumentRoot /srv/www/typo3cms/ersatzdomain.eu
ServerName www.ersatzdomain.eu
ServerAlias ersatzdomain.eu

<Directory /srv/www/typo3cms/ersatzdomain.com/>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>

ServerSignature On

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.ersatzdomain.eu$ [NC]
RewriteRule ^(.*) https://www.ersatzdomain.com$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^ersatzdomain.eu$ [NC]
RewriteRule ^(.*) https://www.ersatzdomain.com$1 [L,R=301]
</VirtualHost>

<VirtualHost 192.168.1.7:80>
ServerAdmin hostmaster@ersatzdomain.com
DocumentRoot /srv/www/typo3cms/ersatzdomain.com
ServerName www.ersatzdomain.com
ServerAlias ersatzdomain.com

<Directory /srv/www/typo3cms/ersatzdomain.com/>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>

ScriptAlias /scripts "/srv/www/typo3cms/ersatzdomain.com/scripts/"

<Directory "/srv/www/typo3cms/ersatzdomain.com/scripts/">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>

Alias /Admin "/srv/www/typo3cms/ersatzdomain.com/typo3/"

<Directory "/srv/www/typo3cms/ersatzdomain.com/typo3/">
Options -Indexes +MultiViews +FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ScriptAlias /cgi-bin/ "/srv/www/typo3cms/ersatzdomain.com/cgi-bin/"

<Directory "/srv/www/typo3cms/ersatzdomain.com/cgi-bin/">
AllowOverride None
Options +ExecCGI
AddHandler cgi-script .cgi .pl
Require all granted
</Directory>

ErrorLog /var/log/apache2/www.ersatzdomain.com-error.log

LogLevel warn

CustomLog /var/log/apache2/www.ersatzdomain.com-access.log combined
ServerSignature On

RewriteEngine on
LogLevel alert rewrite:trace3
RewriteCond %{HTTP_HOST} ^www.ersatzdomain.com$ [NC]
RewriteRule ^(.*) https://www.ersatzdomain.com$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^ersatzdomain.com$ [NC]
RewriteRule ^(.*) https://ersatzdomain.com$1 [L,R=301]

</VirtualHost>

# StartSSL:
<VirtualHost *:443>
ServerName www.ersatzdomain.com
DocumentRoot /srv/www/typo3cms/ersatzdomain.com

<Directory /srv/www/typo3cms/ersatzdomain.com/>
Options +Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>

SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile /etc/startssl/ersatzdomain.com/ersatzdomain.com.crt
SSLCertificateKeyFile /etc/startssl/ersatzdomain.com/ersatzdomain.com.key
SSLCertificateChainFile /etc/startssl/sub.class1.server.ca.pem
SSLCACertificateFile /etc/startssl/ca.pem
</VirtualHost>
Wenn ich im Browser "https://www.ersatzdomain.com" aufrufe, dann wird mir die Website angezeigt. "http://www.ersatzdomain.com" oder ""http://www.ersatzdomain.eu" liefert im Error-Logfile die Meldung


[Wed Dec 02 17:44:28.437429 2015] [authz_core:error] [pid 24970] [client 93.231.150.22:36620] AH01630: client denied by server configuration: /srv/www/typo3cms/


bzw. im Access-Logfile


93.231.150.22 - - [02/Dec/2015:17:47:46 +0100] "GET / HTTP/1.1" 403 512 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0"

apache2ctl -t -D DUMP_MODULES
[Wed Dec 02 17:49:56.302630 2015] [core:error] [pid 25496] (EAI 2)Name or service not known: AH00547: Could not resolve host name + -- ignoring!
Loaded Modules:
core_module (static)
so_module (static)
watchdog_module (static)
http_module (static)
log_config_module (static)
logio_module (static)
version_module (static)
unixd_module (static)
access_compat_module (shared)
alias_module (shared)
auth_basic_module (shared)
authn_core_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
fcgid_module (shared)
filter_module (shared)
mime_module (shared)
mpm_prefork_module (shared)
negotiation_module (shared)
php5_module (shared)
proxy_module (shared)
proxy_http_module (shared)
rewrite_module (shared)
setenvif_module (shared)
socache_shmcb_module (shared)
ssl_module (shared)
status_module (shared)
Wie bekomme ich das Rewriting wieder zum Laufen?

Gruß
Wambui

marce
07.12.15, 11:03
Auf den ersten Blick sieht die Konfig gut aus. Daher würde ich einfach mal vernuten, daß es evtl. mit den Verzeichnisrechten zu tun hat.

Wambui
07.12.15, 11:21
Danke für das Lob.

Auf den ersten Blick sieht die Konfig gut aus. Daher würde ich einfach mal vernuten, daß es evtl. mit den Verzeichnisrechten zu tun hat.
Alles gehört dem www-data "drwxr-xr-x 9 www-data www-data". Wenn die Rechte nicht stimmen würden, hätte ich das bereits daran gemerkt, dass die Website überhaupt nicht angezeigt würde. Das Problemist nur beim Rewrite.
Ich habe jetzt einmal den LogLevel auf debug gesetzt. Dann erhalte ich folgende Meldungen

[Mon Dec 07 11:20:37.056070 2015] [authz_core:debug] [pid 17700] mod_authz_core.c(809): [client 93.193.101.183:50961] AH01626: authorization result of Require all denied: denied
[Mon Dec 07 11:20:37.056106 2015] [authz_core:debug] [pid 17700] mod_authz_core.c(809): [client 93.193.101.183:50961] AH01626: authorization result of <RequireAny>: denied
[Mon Dec 07 11:20:37.056111 2015] [authz_core:error] [pid 17700] [client 93.193.101.183:50961] AH01630: client denied by server configuration: /srv/www/typo3cms/

marce
07.12.15, 11:27
Das deutet darauf hin, daß da irgendwo, in einer anderen Konfig-datei, noch ein Require all denied oder Require ip steht...

Deine Apache-Konfig besteht ja nicht nur aus den beiden oben geposteten Blocks. Also mal suchen. Könnte ggf. auch eine .htaccess sein.

Wambui
07.12.15, 11:39
Prima, besten Dank. Das hat erst einmal teilweise weitergeholfen.
In der apache.conf habe ich mit grep -R denied * das hier gefunden

<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>


Das habe ich zu

<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>

<Directory /srv/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

geändert. Auf "/" will ich ja keinen Zugriff.
Dafür sehe ich anstelle der Website den "Index of /" von /srv/www/. Das will ich ja auch nicht. Wie gesagt, das hat unter dem alten Apache 2.2 noch bestens funktioniert.

marce
07.12.15, 11:45
Ist das NameBased-VHosting? Sicher, daß der richtige VHost ausgewählt wird? Sieht irgendwie eher nach dem Default-Host aus. Pack' mein ein Error- und Access-Log in den VHost und schau, ob der Request da wirklich ankommt...