为 cloudfoundry 应用程序配置 nginx 路由

Ken*_*Lee 6 nginx cloud-foundry

我在 www.mycompany.com 上部署了一个静态 cloudfoundry 应用程序

当用户访问 www.mycompany.com/rate 时,我希望将页面转发到 myrate.apps.mycompany.com/summary

静态应用程序包含 nginx.conf。以下是我的有效配置。

server {
    listen <%= ENV["PORT"] %>;
    server_name localhost;

    location = /rate {
        proxy_pass http://myrate.apps.mycompany.com/summary;
    }

    location = /rate/ {
        proxy_pass http://myrate.apps.mycompany.com/summary;
    }
}
Run Code Online (Sandbox Code Playgroud)

问题就在这里。http://myrate.apps.mycompany.com/summary正在使用一些 css 和 js 文件:

我如何代理这些资源?

如果没有任何代理,则会导致 404 www.mycompany.com/rate/js/myjs.js

干杯,肯

Dan*_*ham -1

您可以使用“staticfile”构建包推送您的应用程序并指定自定义 Nginx 配置!请参阅http://docs.cloudfoundry.org/buildpacks/staticfile/index.html#custom_nginx_configurationhttps://github.com/cloudfoundry/staticfile-buildpack

  • 应该指出的是,这个答案已经过时了。PCF 现在提供 NGINX 构建包(请参阅:https://docs.cloudfoundry.org/buildpacks/nginx/index.html),它还支持自定义 NGINX 配置。 (4认同)