同一虚拟主机名称出现在多个虚拟主机配置文件中-Apache VirtualHost配置

时间:2020-05-06 23:27:57

标签: apache ssl configuration virtualhost vhosts

这似乎是矛盾的,因为同一个名称“ prominenthair.hr”出现在多个虚拟主机配置文件中:

  • 端口443的名称vhost excellenthair.hr(/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
  • 端口443的名称vhost excellenthair.hr(/etc/apache2/sites-enabled/prominenthair.hr.conf:6)

由于两个文件的内容不同,因此如何将数据构造为一个.conf文件?

000-default-le-ssl.conf

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

        <Directory /var/www/html/>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName prominenthair.hr
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/prominenthair.hr/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/prominenthair.hr/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

prominenthair.hr.conf

<VirtualHost *:80>
   ServerName prominenthair.hr
   Redirect permanent / https://prominenthair.hr/
</VirtualHost>

<VirtualHost *:443>
        ServerAdmin mario.orlovac@gmail.com
        ServerName prominenthair.hr
        ServerAlias www.prominenthair.hr
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        SSLEngine on
        SSLCertificateFile    /etc/letsencrypt/live/www.prominenthair.hr/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/www.prominenthair.hr/privkey.pem
        SSLCertificateChainFile /etc/letsencrypt/live/www.prominenthair.hr/chain.pem

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =prominenthair.hr
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

当前:

root @ www:/ etc / apache2 / sites-available#ls

  • 000-default.conf
  • 000-default.conf.dpkg-dist
  • 000-default-le-ssl.conf
  • default-ssl.conf
  • prominenthair.hr.conf
  • prominenthair.hr-le-ssl.conf
  • salonkristina.hr.conf

其他信息:

  • 我的Web服务器是:Apache / 2.4.18(Ubuntu)
  • 我的Web服务器运行的操作系统是:Ubuntu 16.04
  • 我的托管服务提供商:Digital Ocean
  • 我的客户端版本是:certbot 0.31.0

我的原始帖子开始于here

0 个答案:

没有答案