我有这个nginx配置来提供rails应用程序:location ^~ /api/ {alias /srv/www/rails/public/;try_files $uri @unicorn;}location @unicorn {proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_...
我有这个nginx配置来提供rails应用程序:
location ^~ /api/ {
alias /srv/www/rails/public/;
try_files $uri @unicorn;
}
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:2007;
}
我想从路径的开头删除/ api /,然后将其传递给rails app,但由于它是一个命名位置,我不能在proxy_pass指令的末尾添加“/”,如何在传递请求之前删除/ api /到铁轨?
解决方法:
使用:
location @unicorn {
rewrite ^/api(.*)$$1 break;
...
}
有关详情,请参见this document.
沃梦达教程
本文标题为:ruby-on-rails – nginx:从命名位置的proxy_pass中删除路径
基础教程推荐
猜你喜欢
- ruby-on-rails – Nginx支持的Rails应用程序中缺少Content-Length Header 2023-09-20
- go语言的魔幻旅程14-反射 2023-09-05
- R语言多元线性回归实例详解 2022-12-15
- R语言使用gganimate创建可视化动图 2022-12-10
- R语言histogram(直方图)的具体使用 2022-10-28
- R语言关联规则深入详解 2022-11-08
- R语言学习代码格式一键美化 2022-12-05
- Go语言实现一个Http Server框架(二) Server的抽象 2023-07-25
- golang 自然语言处理工具(gohanlp) 2023-09-05
- Ruby on Rails在Ping ++ 平台实现支付 2023-07-22
