2016-05-05 123 views
1

我試圖設置清漆和Apache從一個VPS服務多個網站。但是,當我在瀏覽器中輸入seconddomain.nl時,我被重定向到默認的apache2開始頁面(帶有一個爲VPS IP地址的URL)。然而,firstdomain.nl工作得很好。我的設置是這樣的:如何使用多個apache虛擬主機設置清漆4.1.2?

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 [email protected] 
     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 [email protected] 
     ServerName seconddomain.nl 
     ServerAlias www.seconddomain.nl 
     DocumentRoot /var/www/jws 

     php_admin_value sendmail_path "/usr/sbin/sendmail -t -i [email protected] 
     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 [email protected] 
     ServerName firstdomain.nl 
     ServerAlias www.firstdomain.nl 
     DocumentRoot /var/www/firstdomain.nl 

     php_admin_value sendmail_path "/usr/sbin/sendmail -t -i [email protected]$ 
     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> 
+1

它沒有光油嗎? (如果你使用兩個域名瀏覽到:8080) – Jensd

+0

@Jensd在我的本地機器上使用curl和瀏覽器時出現:無法連接到seconddomain.nl端口8080:操作超時。第一個域相同。 在VPS我得到連接拒絕(兩者)。 – Flobin

+0

然後你的問題是與Apache或服務器本身 - 而不是清漆!任何防火牆運行? – Jensd

回答

0

我有相同的配置,你的,有什麼解決它是刪除/ etc中的127.0.0.1 /apache2/ports.conf

This是我現在如何和它的工作原理(我評論了改變後的產品線):

# 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>