为什么在Apache ServerName上使用Nginx反向代理

时间:2019-01-05 16:39:41

标签: apache nginx reverse-proxy virtualhost

我一直在阅读有关人们在其家庭/自托管设置中使用反向代理的信息,那里的一台服务器可能托管多个站点。我试图理解为什么在Apache中使用反向代理而不是仅使用不同的虚拟主机,而每个虚拟主机具有不同的ServerName。

例如,这是我能够访问同一服务器但根据URL提供不同内容的方法:

<VirtualHost *:80>
    DocumentRoot /var/www/url1
    ServerName url1.ddns.net

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

    <Directory /var/www/url1/>
        Options +FollowSymlinks
        AllowOverride All

        <IfModule mod_dav.c>
            Dav off
        </IfModule>

        SetEnv HOME /var/www/url1
        SetEnv HTTP_HOME /var/www/url1
        Satisfy Any
    </Directory>

    Redirect / https://url1.ddns.net
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /var/www/url2
    ServerName url2.ddns.net

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

    <Directory /var/www/url2/>
        Options +FollowSymlinks
        AllowOverride All

        <IfModule mod_dav.c>
            Dav off
        </IfModule>

        SetEnv HOME /var/www/url2
        SetEnv HTTP_HOME /var/www/url2
        Satisfy Any
    </Directory>

    Redirect / https://url2.ddns.net
</VirtualHost>

0 个答案:

没有答案