两年来,我一直在运营一个愚蠢的小网站:mtgpilot.com
在几个证书过期之前,该站点一直运行良好。我决定创建一个新的AWS Lightsail实例并再次设置站点。我遵循了第一次创建站点时使用的所有相同步骤,只是现在每当我尝试向服务器发出post或get请求时,都会得到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进行后端调用也会失败,并返回0未知错误的http失败响应。
我也认为这可能是CORS错误,但我有fixed this issue before。
任何帮助都是非常感谢的。该网站现在是活的,我已经链接到所有相关的代码,以允许反向工程。
发布于 2020-07-14 13:41:52
维尔萨德给了我一个解决这个问题的办法。事实证明这与代码一点关系都没有。只需通过Amazon Lightsail UI配置允许端口8080。
https://stackoverflow.com/questions/62887525
复制相似问题