adiux
adiux

Reputation: 73

How to force https on Swisscom cloud foundry with Staticfile Buildpack (FORCE_HTTPS)

I configured the env option FORCE_HTTPS = true as suggested in the documentation:

My manifext.yml

env:
  APP_ENV: production
  FORCE_HTTPS: true

However, when I open the website with http I do not get redirected to https.

I use a custom nginx.conf file

The setting was applied

Upvotes: 2

Views: 1014

Answers (1)

adiux
adiux

Reputation: 73

I added the following line to my custom '/nginx.conf' file.

    location / {
        <% if ENV["FORCE_HTTPS"] %>
            if ($http_x_forwarded_proto != "https") {
                return 301 https://$host$request_uri;
            }
        <% end %>
        ...
    }

Upvotes: 1

Related Questions