簡體   English   中英

如何使用多個apache虛擬主機設置varnish 4.1.2?

[英]How to set up varnish 4.1.2 with multiple apache virtual hosts?

我正在嘗試設置Varnish和Apache,以從一個VPS服務多個網站。 但是,當我在瀏覽器中輸入seconddomain.nl時,我將重定向到默認的apache2起始頁(其URL為VPS IP地址)。 但是,firstdomain.nl可以正常工作。 我的設置是這樣的:

etc/default/varnish

DAEMON_OPTS="-a :80 \
             -T localhost:1234 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

(省略了某些部分)

/etc/varnish/default.vcl

backend default {
    .host = "127.0.0.1";
    .port = "8080";
}

/etc/apache2/ports.conf

NameVirtualHost *:8080
Listen 127.0.0.1:8080

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

/etc/apache2/sites-available/000-default.conf

<VirtualHost *:8080>
        ServerName 188.166.71.35

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

         <Directory /var/www/jws/>
            AllowOverride All
         </Directory>

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

/etc/apache2/sites-available/seconddomain.nl.conf

<VirtualHost *:8080>

        ServerAdmin janwillem@seconddomain.nl
        ServerName seconddomain.nl
        ServerAlias www.seconddomain.nl
        DocumentRoot /var/www/jws

        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fjanwillem@seconddomain.nl
        ErrorLog ${APACHE_LOG_DIR}/error-seconddomain.log
        CustomLog ${APACHE_LOG_DIR}/access-seconddomain.log combined
</VirtualHost>

/etc/apache2/sites-available/firstdomain.nl.conf

<VirtualHost *:8080>

        ServerAdmin info@firstdomain.nl
        ServerName firstdomain.nl
        ServerAlias www.firstdomain.nl
        DocumentRoot /var/www/firstdomain.nl

        php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -finfo@cool-hou$
        ErrorLog ${APACHE_LOG_DIR}/error-firstdomain.log
        CustomLog ${APACHE_LOG_DIR}/access-firstdomain.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =firstdomain.nl [OR]
RewriteCond %{SERVER_NAME} =www.firstdomain.nl
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

我的配置與您的配置相同,解決的方法是刪除/etc/apache2/ports.conf中的127.0.0.1

這就是我現在的工作方式(我評論了更改的行):

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

#Listen 127.0.0.1:8080
Listen 8080

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM