Apacheredirect到其他服务器与子域

我目前正在运行托pipe我的networking和gitlab服务器的CentOS以及托pipe一个亚音速服务器的Windows机器。 目前,我的IP指向CentOS,但没有正确redirect。 我能够访问/但无法访问任何其他网站的子域,尽pipe我已经做了设置,所以我想知道我要去哪里错了,如何纠正这个问题。 当人们inputhttp://git.example.com ,是否也可能自动将其redirect到https://git.example.com ? 提前致谢!

 NameVirtualHost *:80 #This should lead to subsonic server <VirtualHost *> ServerName music.company.com ServerAlias www.music.company.com ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyErrorOverride On ProxyPass / http://192.168.1.14:6060/ ProxyPassReverse / http://192.168.1.14:6060/ <Location /> Order allow,deny Allow from all </Location> </VirtualHost> 

Gitlab.conf

 LoadModule ssl_module modules/mod_ssl.so SSLSessionCache "shmcb:logs/ssl_scache(512000)" <VirtualHost *:443> SSLEngine on #strong encryption ciphers only #see ciphers(1) http://www.openssl.org/docs/apps/ciphers.html SSLCipherSuite SSLv3:TLSv1:+HIGH:!SSLv2:!MD5:!MEDIUM:!LOW:!EXP:!ADH:!eNULL:!aNULL SSLCertificateFile /etc/pki/tls/certs/ca.crt SSLCertificateKeyFile /etc/pki/tls/private/ca.key SSLCACertificateFile /etc/pki/tls/certs/ca.crt ServerName 127.0.0.1 ServerSignature Off ProxyPreserveHost On <Location /> Order deny,allow Allow from all ProxyPassReverse http://127.0.0.1:8080 ProxyPassReverse http://127.0.0.1/ </Location> #apache equivalent of nginx try files # http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files # http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab RewriteEngine on RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f RewriteRule .* http://127.0.0.1:8080%{REQUEST_URI} [P,QSA] RequestHeader set X_FORWARDED_PROTO 'https' # needed for downloading attachments DocumentRoot /home/git/gitlab/public #Set up apache error documents, if back end goes down (ie 503 error) then a maintenance/deploy page is thrown up. ErrorDocument 404 /404.html ErrorDocument 422 /422.html ErrorDocument 500 /500.html ErrorDocument 503 /deploy.html LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded ErrorLog /var/log/httpd/logs/gitlab.example.com_error.log CustomLog /var/log/httpd/logs/gitlab.example.com_forwarded.log common_forwarded CustomLog /var/log/httpd/logs/gitlab.example.com_access.log combined env=!dontlog CustomLog /var/log/httpd/logs/gitlab.example.com.log combined </VirtualHost> 

你有一个不匹配的

 NameVirtualHost *:80 

 <VirtualHost *> 

您需要将VirtualHost更改为与NameVirtualHost相同,即

 <VirtualHost *:80> 

至于redirect,vic的答案应该有帮助 – 如果没有,看看redirect,更改url或redirectHTTP到HTTPS的Apache – 你想知道的所有关于Mod_Rewrite规则,但不敢问

使用他们为我工作的这些规则:

 RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) (https)://%{HTTP_HOST}%{REQUEST_URI} RewriteEngine On RewriteRule ^apache-redirect-http-to-https\.html$ (https)://www.yoursite.com/apache-redirect-http-to-https.html [R=301,L] 

注意:使用https链接删除()。 这些是我的configuration:

 NameVirtualHost *:80 <VirtualHost *:80> ServerName mysite.example.com DocumentRoot /usr/local/apache2/htdocs Redirect permanent / https://mysite.example.com/ </VirtualHost> <VirtualHost _default_:443> ServerName mysite.example.com DocumentRoot /usr/local/apache2/htdocs SSLEngine On # etc... </VirtualHost> 

我知道我真的很晚参加派对,但是当我正在寻找答案时,它显示在search引擎的顶端。 这个对我来说就像一个魅力:

 <VirtualHost YOUR.SERVERS.IP.HERE:80> RewriteEngine on ReWriteCond %{SERVER_PORT} !^443$ RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L] </VirtualHost>