gpt4 book ai didi

apache - 如何使用多个apache虚拟主机设置varnish 4.1.2?

转载 作者:行者123 更新时间:2023-12-03 17:45:33 25 4
gpt4 key购买 nike

我正在尝试设置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>

关于apache - 如何使用多个apache虚拟主机设置varnish 4.1.2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37060516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com