这是一个电子邮件服务器,其他人似乎都在使用相同的设置运行。出于某种原因,它对我不起作用,并且之前的“502 nginx docker”或“recv failed Connection reset by peer”的答案都没有解决它。也许这与my Nginx Vhost setup有关?
该网站在serverIP:5870上正确加载,如果我将proxy_pass http://127.0.0.1:5870;
更改为proxy_pass http://example.com:5870;
,则它将在example.com:5870上加载。但当我访问没有端口的网站时,它会出现502错误。
如果我设置proxy_pass http://127.0.0.1:5870;
并访问example.com:5870,我得到:
The connection for this site is not secure
example.com sent an invalid response.
Try running Windows Network Diagnostics.
ERR_SSL_PROTOCOL_ERROR
字符串
如果我将proxy_pass更改为http://example.com:5870;
,则会加载example.com,但会出现一个包含基本文本的“破碎”页面,URL为http://localhost:9000/subscription/form”。
Broken listmonk homepage image的
docker-compose.yml:
version: "3.7"
x-app-defaults: &app-defaults
restart: unless-stopped
image: listmonk/listmonk:latest
ports:
- "5870:9000"
networks:
- listmonk
environment:
- TZ=Etc/UTC
x-db-defaults: &db-defaults
image: postgres:13
ports:
- "9432:5432"
networks:
- listmonk
environment:
- POSTGRES_PASSWORD=pw
- POSTGRES_USER=listmonk
- POSTGRES_DB=listmonk
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U listmonk"]
interval: 10s
timeout: 5s
retries: 6
services:
db:
<<: *db-defaults
container_name: listmonk_db
volumes:
- type: volume
source: listmonk-data
target: /var/lib/postgresql/data
app:
<<: *app-defaults
container_name: listmonk_app
depends_on:
- db
volumes:
- ./config.toml:/listmonk/config.toml
- ./uploads:/listmonk/uploads
networks:
listmonk:
volumes:
listmonk-data:
型
nginx配置:
server {
listen 443 ssl;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:5870;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80;
server_name example.com;
location / {
return 301 https://$host$request_uri;
}
}
型
nginx错误日志显示2023/11/22 17:54:00 [error] 54579#54579: *2 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: <myip>, server: example.com, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:5870/", host: "example.com"
“recv failed 104 Connection reset by peer while阅读response header from upstream”的搜索结果都说这是一个php-fpm问题。但我还没有找到任何解决方案。php-fpm:
sudo netstat -nlpt |grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1175/php-fpm: maste
型
我尝试了proxy_pass
的许多变体:
proxy_pass http://example.com:5870;
个proxy_pass http://<SERVER_IP>:5870;
-与上面的结果相同。proxy_pass http://0.0.0.0:5870;
与127.0.0.1:5870相同。proxy_pass http://example.com/;
导致“ERR_TOO_MANY_REDIRECTS”。proxy_pass http://listmonk_app:5870;
、proxy_pass http://app:5870;
和proxy_pass http://listmonk:5870;
都导致nginx errors。
我找到这个nginx resolving localhost on proxy pass并运行:
curl 127.0.0.1:5870
curl: (56) Recv failure: Connection reset by peer
curl 0.0.0.0:5870
curl: (56) Recv failure: Connection reset by peer
curl 127.0.0.1:9000
curl: (56) Recv failure: Connection reset by peer
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6738da252977 listmonk/listmonk:latest "./listmonk" 3 weeks ago Up 47 hours 0.0.0.0:5870->9000/tcp, :::5870->9000/tcp listmonk_app
f8d43916e568 postgres:13 "docker-entrypoint.s…" 3 weeks ago Up 47 hours (healthy) 0.0.0.0:9432->5432/tcp, :::9432->5432/tcp listmonk_db
sudo netstat -nlpt |grep 5870
tcp 0 0 0.0.0.0:5870 0.0.0.0:* LISTEN 2757/docker-proxy
tcp6 0 0 :::5870 :::* LISTEN 2762/docker-proxy
的字符串
我在这里尝试了一些解决方案https://serverfault.com/questions/351212/nginx-redirects-to-port-8080-when-accessing-url-without-slashproxy_set_header Host $host:$server_port;
似乎没有改变任何东西。
我也试
proxy_pass http://example.com:5870/;
proxy_redirect http://example.com:5870/ http://example.com/;
型
也许这个NodeJs on nginx not working without a port number in the url是答案,但我不明白。
1条答案
按热度按时间nuypyhwy1#
是防火墙的问题。我关闭了我的防火墙,它还能用。