我的任务是使用nginx修复我公司的一个演示站点中的一些问题。我以前接触nginx的机会非常有限。
当前,当某人导航到https://blah.demo.site.com并单击指向其他任何页面的任何链接(例如产品页面)时,他们被发送到https://blah.demo.site.com/blah/products并收到错误404。我们想要发生的是点击实际发送到https://blah.demo.site.com/products
的链接以下是/etc/nginx/conf.d/
中我们当前的nginx配置文件。我如何弄清楚我们在做错什么?
server {
server_name blah.demo.site.com;
access_log /home/company/site/current/log/blah_nginx.access.log;
error_log /home/company/site/current/log/blah_nginx.error.log info;
client_max_body_size 200M;
client_body_buffer_size 128k;
location ^~ /pcl/packs {
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host demo.site.com;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Host admin.demo.site.com;
proxy_set_header X-Request-Start "t=${msec}";
resolver 8.8.8.8;
proxy_pass https://demo.site.com$request_uri;
}
location ^~ /pcl/assets {
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host demo.site.com;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Host admin.demo.site.com;
proxy_set_header X-Request-Start "t=${msec}";
resolver 8.8.8.8;
proxy_pass https://demo.site.com$request_uri;
}
location ^~ /rails/active_storage {
proxy_redirect off;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host demo.site.com;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Request-Start "t=${msec}";
proxy_set_header X-Forwarded-Host admin.demo.site.com;
resolver 8.8.8.8;
proxy_pass https://demo.site.com$request_uri;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host demo.site.com;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Host admin.demo.site.com;
proxy_set_header X-Company-Admin true;
proxy_set_header X-Request-Start "t=${msec}";
proxy_pass https://demo.site.com/blah/;
proxy_redirect off;
}
listen 80; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/demo.site.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/demo.site.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;