我有两个RPi(3+),都用于LAMP Web服务器。他们的关系就像this image
因此,Rpi1是直接与我的家庭路由器通信的那个,我设置了反向代理来检索RPi2数据。
我的问题是我能够使用其域(static1.com和wordpress1.com)访问两个RPi1网站,但是两个RPi2域(static2.com和wordpress2.com)都指向同一个站点(wordpress2.com)
我认为我在RPi2中的虚拟主机设置有问题,但仍找不到任何线索...我需要帮助来解决此apache设置问题!
这是我在RPi 1 Apache服务器中设置的
static2.com设置:
pi@cloelee:/etc/apache2/sites-available $ cat static2.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName static2.com
ServerAlias www.static2.com
SSLProxyEngine on
ProxyPass / http://192.168.1.18/
ProxyPassReverse / http://192.168.1.18/
ProxyPreserveHost Off
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@example.com
ServerName static2.com
ServerAlias www.static2.com
SSLProxyEngine on
ProxyPass / http://192.168.1.18/
ProxyPassReverse / http://192.168.1.18/
ProxyPreserveHost Off
SSLCertificateFile /etc/letsencrypt/live/static2.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/static2.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
wordpress2.com设置:
pi@cloelee:/etc/apache2/sites-available $ cat wordpress2.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName wordpress2.com
ProxyPass / http://192.168.1.18/
ProxyPassReverse / http://192.168.1.18/
ProxyPreserveHost Off
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@example.com
ServerName wordpress2
ProxyPass / http://192.168.1.18/
ProxyPassReverse / http://192.168.1.18/
ProxyPreserveHost Off
</VirtualHost>
这是我在RPi2 Apache Server中的设置,
static2.com设置:
pi@kyongoh:/etc/apache2/sites-available $ cat static2.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName static2.com
ServerAlias www.static2.com
DocumentRoot /var/www/static2.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(www\.)?static2\.com$
RewriteRule (.*) https://static2.com/$1 [L,R,NE]
</VirtualHost>
pi@kyongoh:/etc/apache2/sites-available $ cat static2.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
ServerName static2.com
ServerAlias www.static2.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/static2.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/static2.com/privkey.pem
</VirtualHost>
</IfModule>
wordpress2.com设置:
pi@kyongoh:/etc/apache2/sites-available $ cat wordpress2.com.conf
<VirtualHost *:80>
<Directory "/var/www/wordpress2.com">
AllowOverride All
</Directory>
ServerName wordpress2.com
ServerAdmin webmaster@local_wordpress
DocumentRoot /var/www/wordpress2.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster@example.com
ServerName wordpress2.com
ServerAdmin webmaster@local_wordpress
DocumentRoot /var/www/wordpress2.com
</VirtualHost>
您可能已经意识到wordpress2.com还没有SSL,但static2.com已经有了SSL。您知道为什么两个RP2域都请求wordpress2数据吗?我想念什么?
感谢帮助!
答案 0 :(得分:0)
这是简单的修复,只是错过了打开ProxyPreserveHost的机会
Name
到
ProxyPreserveHost Off