我有一个带有 puma 和 nginx 的 rails web 服务器,这是配置
upstream puma_mydomain.it {
server unix:/var/apps/mydomain.it/shared/tmp/sockets/mydomain.it-puma.sock fail_timeout=0;
}
server {
listen 80;
listen [::]:80;
server_name mydomain.it www.mydomain.it;
return 301 https://www.mydomain.it$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mydomain.it;
return 301 https://www.$server_name$request_uri;
}
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
ssl on;
ssl_certificate /etc/letsencrypt/live/mydomain.it/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.it/privkey.pem;
server_name www.mydomain.it;
root /var/apps/mydomain.it/current/public;
try_files $uri/index.html $uri @puma_mydomain.it;
client_max_body_size 4G;
keepalive_timeout 10;
error_page 500 502 504 /500.html;
error_page 503 @503;
location @puma_mydomain.it {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
ssi on;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://puma_mydomain.it;
# limit_req zone=one;
access_log /var/apps/mydomain.it/shared/log/nginx.access.log;
error_log /var/apps/mydomain.it/shared/log/nginx.error.log;
}
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
location = /50x.html {
root html;
}
location /helloworld.html {
ssi on;
proxy_set_header Accept-Encoding "";
proxy_pass https://liveblog.mydomain.it/api/upload-raw/blogs/5c20ff839a954a50bec0a4b9/index.html;
}
location = /404.html {
root html;
}
location @503 {
error_page 405 = /system/maintenance.html;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html break;
}
rewrite ^(.*)$ /503.html break;
}
if ($request_method !~ ^(GET|HEAD|PUT|PATCH|POST|DELETE|OPTIONS)$ ){
return 405;
}
if (-f $document_root/system/maintenance.html) {
return 503;
}
}
我已经添加位置“helloworld.html”作为测试:基本上每次我调用mydomain.it/helloworld.html时我都需要nginx打开远程url页面。
我不明白为什么https://mydomain.it/helloworld.html总是返回我的 Rails 应用程序并出现路由错误......