虚拟主机被忽略

时间:2017-08-30 21:14:01

标签: apache mod-rewrite

我的配置忽略了

downloads.example.net。我创建它作为现有主机的附加虚拟主机以进行文件下载。制作文件夹,设置权限,设置两个虚拟主机,一个用于HTTP重写为HTTPS,另一个用于HTTPS。已经有一个虚拟主机为人们提供IP服务,我不想向他们展示任何东西,所以在IP上提供空白页面,没有直接回报的奖励。在一些域上提供了一个WordPress站点,相同的设置,重写为HTTPS。

加入IP并获取/ var / www / html上的空白index.html。来www.example.net,www.example.info,example.net和example.info并获取WordPress网站。在HTTP或HTTPS上下载downloads.example.net并获取WordPress网站。我通常在虚拟主机上没有多个域,或者使用重写来将人们移动到SSL,所以想知道我是否在那里出错。

SSL证书在站点之间共享,因为CloudFlare将自己的证书添加到访问该站点的用户。

<VirtualHost *:80>
    ServerName 111.222.233.244
    ServerAdmin support@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerName downloads.example.net
    ServerAlias downloads.example.info
    ServerAdmin support@example.net
    DocumentRoot /var/www/downloads

    ErrorLog ${APACHE_LOG_DIR}/downloaderror.log
    CustomLog ${APACHE_LOG_DIR}/downloadaccess.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerName www.example.net
    ServerAlias example.net
    ServerAlias www.example.info
    ServerAlias example.info
    ServerAdmin support@example.net
    DocumentRoot /var/www/wordpress

    ErrorLog ${APACHE_LOG_DIR}/exampleerror.log
    CustomLog ${APACHE_LOG_DIR}/exampleaccess.log combined
</VirtualHost>

<IfModule mod_ssl.c>
  <VirtualHost *:443>
    ServerName 111.222.233.244
    ServerAdmin support@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/example.crt
    SSLCertificateKeyFile /etc/apache2/ssl/example.key

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
                    SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
                    SSLOptions +StdEnvVars
    </Directory>
    BrowserMatch "MSIE [2-6]" \
                    nokeepalive ssl-unclean-shutdown \
                    downgrade-1.0 force-response-1.0
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  </VirtualHost>

  <VirtualHost *:443>
    ServerName downloads.example.net
    ServerAlias downloads.example.info
    ServerAdmin support@example.net
    DocumentRoot /var/www/downloads

    ErrorLog ${APACHE_LOG_DIR}/downloaderror.log
    CustomLog ${APACHE_LOG_DIR}/downloadaccess.log combined

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/example.crt
    SSLCertificateKeyFile /etc/apache2/ssl/example.key

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
                    SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
                    SSLOptions +StdEnvVars
    </Directory>

    BrowserMatch "MSIE [2-6]" \
                    nokeepalive ssl-unclean-shutdown \
                    downgrade-1.0 force-response-1.0
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  </VirtualHost>

  <VirtualHost *:443>
    ServerName www.example.net
    ServerAlias example.net
    ServerAlias www.example.info
    ServerAlias example.info
    ServerAdmin support@example.net
    DocumentRoot /var/www/wordpress

    ErrorLog ${APACHE_LOG_DIR}/exampleerror.log
    CustomLog ${APACHE_LOG_DIR}/exampleaccess.log combined

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/example.crt
    SSLCertificateKeyFile /etc/apache2/ssl/example.key

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
                    SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
                    SSLOptions +StdEnvVars
    </Directory>

    BrowserMatch "MSIE [2-6]" \
                    nokeepalive ssl-unclean-shutdown \
                    downgrade-1.0 force-response-1.0
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
  </VirtualHost>
</IfModule>

编辑:

向第一个指令添加IP的第一个建议什么都不做,第一个建议不是正在服务的那个,而是在其中包含域的那个。第二条和第三条评论有一个“重复”的链接,该页面上的建议如下所示。

apache2ctl -t
Syntax OK

apache2ctl -S
VirtualHost configuration:
*:80                   is a NameVirtualHost
     default server 111.222.233.244 (/etc/apache2/sites-enabled/000-default.conf:1)
     port 80 namevhost 111.222.233.244 (/etc/apache2/sites-enabled/000-default.conf:1)
     port 80 namevhost downloads.example.net (/etc/apache2/sites-enabled/000-default.conf:10)
             alias downloads.example.info
     port 80 namevhost www.example.net (/etc/apache2/sites-enabled/000-default.conf:25)
             alias example.net
             alias www.example.info
             alias example.info
*:443                  is a NameVirtualHost
     default server 111.222.233.244 (/etc/apache2/sites-enabled/000-default.conf:43)
     port 443 namevhost 111.222.233.244 (/etc/apache2/sites-enabled/000-default.conf:43)
     port 443 namevhost downloads.example.net (/etc/apache2/sites-enabled/000-default.conf:67)
             alias downloads.example.info
     port 443 namevhost www.example.net (/etc/apache2/sites-enabled/000-default.conf:93)
             alias example.net
             alias www.example.info
             alias example.info
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

禁用SSL并尝试仅使用两台主机的端口80,但下载仍会发送到example.net。

<VirtualHost *:80>        
    ServerName downloads.example.net
    ServerAdmin support@example.net
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:80>
    ServerName example.net
    ServerAlias www.example.net
    ServerAdmin support@example.net
    DocumentRoot /var/www/wordpress

    ErrorLog ${APACHE_LOG_DIR}/ufoerror.log
    CustomLog ${APACHE_LOG_DIR}/ufoaccess.log combined
</VirtualHost>

1 个答案:

答案 0 :(得分:0)

尝试使用-X标志在调试模式下运行apache,然后运行您的请求以查看发生了什么。

increase the loglevel