A porta HTTPS do servidor web Apache redireciona para HTTP com a porta 443

1

No meu trabalho eu instalei o Mediawiki (versão mais recente) em um servidor web Apache 2.4.6 com PHP 5. Everthing funciona bem quando eu quero acessar as páginas wiki localmente e eu configurei um hostname no Mediawiki

$wgServer = https://en.wiki.example.com. 

Agora, uma vez que eu limpe esta configuração de hostname no Mediawik, então ele deve pegar o nome do host que ele recebe webserver. Isso acontece, mas o formato do nome do host é

http://en.wiki.example.com:443 

que é uma URL incorreta (por causa da mistura de HTTP com HTTPS).

Acho que isso é um problema do Apache porque quando eu tento navegar para

https://en.wiki.example.com/wiki 

redireciona para

http://en.wiki.example.com:443/wiki/index.php/Main_Page

e recebo um erro de solicitação inválida. Trailing slash behind wiki não tem nenhum efeito.

VirtualHost:

<VirtualHost *:443>
ServerName https://en.wiki.example.com
ServerAlias https://en.wiki.example.com en.wiki.external.com
Alias /wiki /var/www/wiki-en
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
<Directory /var/www/wiki-en>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
</VirtualHost>

SSL + virtualhost padrão:

Listen 443 https

NameVirtualHost *:443

##
##  SSL Global Context
##
##  All SSL configuration in this context applies both to
##  the main server and all SSL-enabled virtual hosts.
##

SSLStrictSNIVHostCheck off

#   Pass Phrase Dialog:
#   Configure the pass phrase gathering process.
#   The filtering dialog program ('builtin' is a internal
#   terminal dialog) has to provide the pass phrase on stdout.
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog

#   Inter-Process Session Cache:
#   Configure the SSL Session Cache: First the mechanism 
#   to use and second the expiring timeout (in seconds).
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)
SSLSessionCacheTimeout  300

#   Pseudo Random Number Generator (PRNG):
#   Configure one or more sources to seed the PRNG of the 
#   SSL library. The seed data should be of good random quality.
#   WARNING! On some platforms /dev/random blocks if not enough entropy
#   is available. This means you then cannot use the /dev/random device
#   because it would lead to very long connection times (as long as
#   it requires to make more entropy available). But usually those
#   platforms additionally provide a /dev/urandom device which doesn't
#   block. So, if available, use this one instead. Read the mod_ssl User
#   Manual for more details.
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
#SSLRandomSeed startup file:/dev/random  512
#SSLRandomSeed connect file:/dev/random  512
#SSLRandomSeed connect file:/dev/urandom 512

#
# Use "SSLCryptoDevice" to enable any supported hardware
# accelerators. Use "openssl engine -v" to list supported
# engine names.  NOTE: If you enable an accelerator and the
# server does not start, consult the error logs and ensure
# your accelerator is functioning properly. 
#
SSLCryptoDevice builtin
#SSLCryptoDevice ubsec

##
## SSL Virtual Host Context
##

<VirtualHost _default_:443>

# General setup for the virtual host, inherited from global configuration
DocumentRoot "/var/www/html"

# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

#   SSL Engine Switch:
#   Enable/Disable SSL for this virtual host.
SSLEngine on

#   SSL Protocol support:
# List the enable protocol levels with which clients will be able to
# connect.  Disable SSLv2 access by default:
SSLProtocol all -SSLv2

#   SSL Cipher Suite:
#   List the ciphers that the client is permitted to negotiate.
#   See the mod_ssl documentation for a complete list.
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5

#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/certificates/certificate.crt

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/certificates/certificateprivatekey.key

#   Server Certificate Chain:
#   Point SSLCertificateChainFile at a file containing the
#   concatenation of PEM encoded CA certificates which form the
#   certificate chain for the server certificate. Alternatively
#   the referenced file can be the same as SSLCertificateFile
#   when the CA certificates are directly appended to the server
#   certificate for convinience.
#SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt

#   Certificate Authority (CA):
#   Set the CA certificate verification path where to find CA
#   certificates for client authentication or alternatively one
#   huge file containing all of them (file must be PEM encoded)
#SSLCACertificateFile /etc/pki/tls/certs/ca-bundle.crt

#   Access Control:
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

#   SSL Protocol Adjustments:
BrowserMatch "MSIE [2-5]" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

#   Per-Server Logging:
CustomLog logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost> 

Como a localização da folha de estilos e dos scripts está toda resolvida, vejo o mesmo padrão de URL (

http://en.wiki.example.com:443/wiki/load.php....

). O mesmo vale para as variáveis de URL no Mediawiki. Alguém vê o que estou fazendo errado aqui? Desde já, obrigado. Também adicionei sublinhados para remover a formatação de links nessa pergunta.

Editar: urls atualizados.

    
por Patrick 12.01.2016 / 09:04

2 respostas

0

À primeira vista: Você precisa de um SSLEngine on em cada entrada do VirtualHost que precisa dar suporte ao SSL. Por padrão, o mecanismo de protocolo SSL / TLS está desativado para o servidor principal e todos os hosts virtuais configurados.

Além disso, a diretiva ServerAlias deve ser seguida por um hostname não por um URL; deixe de fora o https:// lá.

    
por 12.01.2016 / 09:38
0

Verifique se você tem os mesmos ServerAlias e ServerName listados na seção <VirtualHost *:80> do seu arquivo de configuração. Caso contrário, o Apache não saberá o que fazer com as solicitações não seguras (http) do wiki e, em vez disso, oferecerá a única opção que está disponível, que está disponível na porta 443.

    
por 12.01.2016 / 21:42