我有两个用于 apache 和 nginx 的虚拟主机。域名是 (kevin-fechner.xyz 和 ketogenix.de)
我自己的网站 (kevin-fechner.xyz) 在我只有一个域名时运行良好。但在添加另一个域名后,所有域名(只有两个)都重定向到新域名(ketogenix.de)或报告 502 Bad Gateway。
两个网站均在运行WordPress 的。
环境:
- Ubuntu 16.04
- 阿帕奇/2.4.29
- nginx/1.10.3
- 安全套接字
- http2
卷曲-I: ketogenix.de
HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.3 (Ubuntu)
Date: Fri, 15 Jun 2018 08:39:48 GMT
Content-Type: text/html
Content-Length: 194
Connection: keep-alive
Location: https://ketogenix.de/
kevin-fechner.xyz
HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.3 (Ubuntu)
Date: Fri, 15 Jun 2018 08:39:58 GMT
Content-Type: text/html
Content-Length: 194
Connection: keep-alive
Location: https://kevin-fechner.xyz/
https://downforeveryoneorjustme.com/ - 结果:上涨
虚拟主机
ketogenix.de
nginx 服务器 {
root /var/www/ketogenix.de;
index index.php index.html index.htm index.nginx-debian.html;
server_name ketogenix.de www.ketogenix.de;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php;
}
location /wp-admin/ {
index index.php;
try_files $uri $uri/ /index.php$args;
}
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
# proxy_pass http://127.0.0.1:8080;
proxy_pass http://127.0.0.1:8080$request_uri;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/ketogenix.de/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ketogenix.de/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.ketogenix.de) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = ketogenix.de) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name ketogenix.de www.ketogenix.de;
return 301 https://ketogenix.de$request_uri;
}
阿帕奇
<VirtualHost 127.0.0.1:8080>
ServerAdmin developer.kevinfechner@gmail
ServerName ketogenix.de
ServerAlias www.ketogenix.de
DocumentRoot /var/www/ketogenix.de
<Directory /var/www/ketogenix.de/>
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
kevin-fechner.xyz
nginx
server {
root /var/www/kevin-fechner.xyz;
index index.php index.html index.htm index.nginx-debian.html;
server_name kevin-fechner.xyz www.kevin-fechner.xyz;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php;
}
location /wp-admin/ {
index index.php;
try_files $uri $uri/ /index.php$args;
}
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
# proxy_pass http://127.0.0.1:8080;
# proxy_pass http://127.0.0.1:8080$request_uri;
proxy_pass http://127.0.0.2:8081$request_uri;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/kevin-fechner.xyz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/kevin-fechner.xyz/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = kevin-fechner.xyz) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name kevin-fechner.xyz www.kevin-fechner.xyz;
return 301 https://kevin-fechner.xyz$request_uri;
}
阿帕奇
<VirtualHost 127.0.0.2:8081>
ServerAdmin developer.kevinfechner@gmail
ServerName kevin-fechner.xyz
ServerAlias www.kevin-fechner.xyz
DocumentRoot /var/www/kevin-fechner.xyz
<Directory /var/www/kevin-fechner.xyz/>
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
错误日志
什么也没说
我尝试过的事情
- 添加服务器名称
- 更改 IP 地址
- 更改端口
- 重新启动 nginx 和 apache
我希望你可以帮助我。
注意:我已从虚拟主机文件中删除了我的所有评论。
答案1
看起来你没有Listen 127.0.0.2:8081
向 Apache 配置添加指令。这会导致 502 错误,因为没有进程在端口 8081 上监听。