我正在尝试在我的计算机上设置第二个网络服务器,但是我遇到了虚拟主机的问题,而且我不确定我应该更改哪个文件和什么。
- 我有 1 台运行 SSL 的服务器
- 我能够添加另一台可以正常运行 HTTP 的服务器。
- 当为该域激活 SSL 时,我一直将其重定向到第一个域。
有人能帮我指明正确的方向吗?
有关更多信息,我的路由器指向端口 80 > 80 和 443 > 8443
忽略任何随机拼写错误,它们都是从图片中复制文本而来的
HTTPD配置文件
Listen 443
Listen 80
HTTPD-SSL配置文件
Listen 8443
<VirtualHost _default_:8443>
#
General setup for the virtual host
DocumentRoot"/Library/Webserver/Documents/"
ServerName theintuitiverising.com
ServerAdmin
ErrorLog"/usr/local/var/log/httpd/error_log"
TransferLog"/us/local/var/log/httpd/access_log"
#
#
SSL Engine Switch:
Enable/Disable SSL for this virtual host.
SSLEngine on
#
#
#
#
#
#
#
#
#
#
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. Keep in mind that if you have both an RSA and a DSA certificate you can configure both in parallel (to also allow the use of DSA ciphers, etc.)
Some ECC cipher suites (http://www.ietf.org/rfc/rfc4492.txt)
require an ECC certificate which can also be configured in parallel.
SSLCertificatefile"/usr/local/etc/certbot/certs/live/theintuitiverising.com/fullchain.pem"
#SSLCertificateFile "/us/local/etc/httpd/server-dsa.crt"
#SSLCertificatefile "/us/local/etc/httpd/server-ecc.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.)
ECC keys, when in use, can also be configured in parallel
SSLCertificateKeyFile"/us/local/etc/certbot/certs/live/theintuitiverising.com/privkey.pem"
HTTPD-VHOSTS.conf
‹VirtualHost *:443>
ServerAdmin
DocumentRoot"/Library/WebServer/SBD/"
ServerName https://scottbrookesdesigns.com
ErrorLog"/usr/local/var/log/httpd/scottbrookesdesigns.com-error_log"
CustomLog"/us/local/var/log/httpd/scottbrookesdesigns.com-access_log"cOmmon
SSLEngine on
SSLCertificateFile"/us/local/etc/certbot/certs/live/scottbrookesdesigns.com/fullchain.pem"
SSLCertificateKeyFile"/us/local/etc/certbot/certs/live/scottbrookesdesigns.com/privkey.pem"
</VirtualHost>
«VirtualHost *:443>
ServerAdmin
DocumentRoot"/Library/WebServer/Documents/"
ServerName https://theintuitiverising.com
ErrorLog"/usr/local/var/log/httpd/theintuitiverising.com-error_log"
CustomLog"/us/local/var/log/httpd/theintuitiverising.com-access_log common
SSLEngine on
SSLCertificateFile"/usr/local/etc/certbot/certs/live/theintuitiverising.com/fullchain.pem"
SSLCertificateKeyFile"/us/local/etc/certbot/certs/live/theintuitiverising.com/privkey.pem"
</VirtualHost>
这也是我的 HTaccess 文件,希望它们有用
RewriteEngine On
RewriteCond * (HTTPS) off
RewriteRule ^(.*)$ https: //%{HTTP_HOST}% (REQUEST_URI) IL, R-301]
RewriteCond *{HTTP_HOST) I^theintuitiverising.coms
RewriteRule (.*) https://theintuitiverising.com/$1 [L,R=301]
RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php [L, R]
RewriteEngine On
RewriteCond *{REQUEST_FILENAME) 1-f
RewriteCond *(REQUEST -FILENAME) I-d
RewriteRule blog/ (.*) blog/?id-$1 [L, NC, QSA]
«FilesMatch ". (php[htm|css|¡s|txt)$">
Header set Cache-Control
</FilesMatch>
"max-age-3600, public"
«FilesMatch ". (ico|png|gif|jpg|webm|webp |mp4 |woff2|woff) $">
Header set Cache-Control "max-age=31557600, public
publici
</FilesMatch>
Header unset ETag
FileETag None
RewriteEngine On
RewriteCond *(HITPS) off
RewriteRule ^(.*)$ https: //%{HTTP_HOST}% (REQUEST_URI) [L, R-301]
RewriteCond * (HTTP_HOST} I^scottbrookesdesigns.com
RewriteRule (.*) https://scottbrookesdesigns.com/$1 [L,R-301]
RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php [L, R]
RewriteEngine On
RewriteCond *{REQUEST _FILENAME) 1-f
Rewritecond *(REQUEST _FILENAME) 1-d <FilesMatch ". (php|htm|css|is txt)$">
Header set Cache-Control'"max-age=3600,public"
</FilesMatch>
«FilesMatch ". (ico|png|gif |jpg|webm |webp |mp4 |woff?(woff)s">
Header set Cache-Control "max-age=31557600, publi
public"
</FilesMatch>
Header unset ETag
FileETag None
答案1
ServerName
不是一个 URL,只是名称。
此外,如果您的 Apache 通过端口 8443 访问,那么您需要在 VirtualHost 定义中反映这一点。
<VirtualHost *:8443>
ServerName scottbrookesdesigns.com
# ...
<VirtualHost *:8443>
ServerName theintuitiverising.com