我有两个apache webservers,每个都运行在一个单独的raspberry pi上。 Pi A运行网站1,pi B运行网站2. Pi A也设置为我的DNS服务器(并且在/ etc / hosts中有pi B&#s信息),我的路由器将端口80和443转发到它。在我的本地网络上一切都很好,我可以访问这两个网站。在网络上我只能访问网站1.当我尝试访问网站2时,我只从pi A获得默认的apache页面。有什么想法吗?
答案 0 :(得分:0)
您可以使用类似的虚拟主机配置在前端配置nginx:
server {
listen 443;
server_name _;
ssl on;
ssl_certificate /srv/nginx/file.crt;
ssl_certificate_key /srv/nginx/file.key;
location /site1 {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://127.0.0.1:8443;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /site2 {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://192.168.0.20:8443;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
Nginx安装非常简单:
yum install nginx
service nginx start
此外,您还需要编辑apache端口,例如默认为8080或8443。