【发布时间】:2020-11-03 08:06:25
【问题描述】:
我已经经营一个愚蠢的小网站大约两年了:mtgpilot.com
网站运行良好,直到一些证书过期。我决定创建一个新的 AWS Lightsail 实例并再次设置该站点。我遵循了我第一次创建站点时使用的所有相同步骤,但现在每当我尝试向服务器发帖或获取请求时,我都会得到 20 秒的超时。
堆栈使用 Angular(代码 here)和 Spring Boot(代码 here)。我的 nginx 配置如下:
# HTTP server
server {
listen 80;
server_name www.mtgpilot.com;
location / {
# First attempt to serve request as file, then
# as directory, then redirect to index(angular) if no file found.
try_files $uri $uri/ /index.html;
}
# redirects both www and non-www to https
return 301 https://mtgpilot.com$request_uri;
include "/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf";
include "/opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf";
}
server {
listen 80;
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then redirect to index(angular) if no file found.
try_files $uri $uri/ /index.html;
}
# redirects both www and non-www to https
return 301 https://mtgpilot.com$request_uri;
include "/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf";
include "/opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf";
}
# HTTPS server
server {
location / {
try_files $uri $uri/ /index.html;
}
listen 443 ssl;
server_name localhost;
if ($host != "mtgpilot.com") {
return 301 https://mtgpilot.com$request_uri;
}
ssl_certificate server.crt;
ssl_certificate_key server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
include "/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf";
include "/opt/bitnami/nginx/conf/bitnami/bitnami-apps-prefix.conf";
}
include "/opt/bitnami/nginx/conf/bitnami/bitnami-apps-vhosts.conf";
我使用letsencrypt创建了我的证书。 Nginx 基于this guide 指向这些。我的后端配置为指向我也添加到 java 密钥库中的同一个证书。
我已经尝试了我能想到的所有可能的配置组合。我的堆栈是一个非常标准的用例,因此必须有一些我可以使用的相关资源。我觉得我已经浪费了大量时间,因为一些简单的配置不正确。
即使为后端调用切换到 http 也会失败,http 失败响应为 0 未知错误。
我也认为这可能是一个 CORS 错误,但我有 fixed this issue before。
感谢任何帮助。该网站现已上线,我已链接到所有相关代码以进行逆向工程。
【问题讨论】:
-
你检查了安全组,确保端口被允许
标签: angular spring-boot nginx https