如何解决安装后 nginx 请求随机挂起
我的网站(Angular + Spring Boot 2)位于 4 核 VPS 上,6GB RAM 映射到子域上。一切都在 Docker Swarm 中。我有 5 个容器:
- jhipster-registry:v5.0.2
- mysql:5.7.22
- elasticsearch:6.8.4
- 搬运工:最新
- 我的申请
我曾经直接在端口 443 上使用我的应用程序,我总是在 https 中访问它,没有任何问题。表演很棒。 现在我已将端口设置为 8081 并安装了 nginx(在 VPS 上,而不是在 Docker 容器中)对我的应用程序执行反向代理。 Nginx 配置
server {
listen 80;
server_name subdomain.site.com;
return 301 https://subdomain.site.com$request_uri;
}
server {
listen 443 ssl;
server_name subdomain.site.com;
access_log /var/log/nginx/site_access.log;
error_log /var/log/nginx/site_error.log;
ssl_certificate /path_to_cert;
ssl_certificate_key /path_to_key;
error_page 500 502 503 504 /500.html;
location /500.html {
root /srv/static/website/maintenance;
}
location / {
proxy_pass https://localhost:8081;
}
}
现在发生的事情是很多请求(随机的,不是每次都一样)被卡在待处理状态。 Here is a chrome dev tools network tab。它发生在 API 调用和资源(图像等)上。 数百个请求的 nginx 错误日志是这样的:
2021/03/19 09:55:41 [error] 7580#7580: *1429 upstream timed out (110: Connection timed out) while connecting to upstream,client: ip.address,server: subdomain.site.com,request: "GET /api/call HTTP/1.1",upstream: "https://[::1]:8081/api/call",host: "subdomain.site.com",referrer: "https://subdomain.site.com/"
2021/03/19 09:55:56 [error] 7580#7580: *1285 upstream timed out (110: Connection timed out) while connecting to upstream,referrer: "https://subdomain.site.com/"
2021/03/19 09:56:11 [error] 7580#7580: *1331 upstream timed out (110: Connection timed out) while connecting to upstream,referrer: "https://subdomain.site.com/"
我将问题与 nginx 配置联系起来,因为在将它安装到那里之前完全没有问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。