Ghost: using https in config.js causes "to many redirects"

Created on 31 Oct 2014  路  13Comments  路  Source: TryGhost/Ghost

when im using this, there is no https in rss (the links still have "http" prefixes)

production: {
        url: 'http://test.de',
        urlSSL: 'https://test.de',

when im chaning the "url" to https, this causes an fatals error "to many redirects"

Most helpful comment

Chris is correct. Here is a working Nginx configuration:

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://127.0.0.1:2368;
}

All 13 comments

If this is indeed the error, I'll fix it tonight. Could you provide some more information?

See the contributing guide

im using a reverse proxy (nginx):

server {
    listen 443 ssl;
    server_name xxx.de;

    ssl on;
    ssl_certificate "/etc/nginx/ssl/xxx.crt";
    ssl_certificate_key "/etc/nginx/ssl/xxx.key";

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}

server {
    listen         80;
    server_name    xxx.de;
    return         301 https://$server_name$request_uri;
}

config.js:

production: {
        url: 'http://xxx.de',
        urlSSL: 'https://xxx.de',
        mail: {},
        database: {
            client: 'mysql',
            connection: {
                host: '127.0.0.1',
                user: 'web-ghost',

                /* You can only connect to MySQL from 127.0.0.1 ;) */
                password: 'xxx',
                database: 'xxx',
                charset: 'utf8'
            }
        },
        server: {
            host: '0.0.0.0',
            port: '2368'
        }
    }

so... if i let the http in the "url" i get the site via https (cause of nginx).. BUT in rss... all the links starts with "http"... so i thought this would be because all links are generated from "url"... so i changed the "url" to https... but then... all browser tell me "to many redirects"..

sry today i dont have time to go though "the contributing guide"... maybe tomorrow

btw... im using all the latest stuff... node10.33 ghost 5.3... etc

Maybe you can watch here. https part translated from official doc
https://dsy.im/posts/setup-ghost-blog-system-on-debian/

@ericrange here is the guide to setting up SSL: http://support.ghost.org/setup-ssl-self-hosted-ghost/ and here is the documentation about the configuration options for SSL: http://support.ghost.org/config/#ssl.

You need to set your main url to be HTTPS, not provide urlSSL as this is for if you want to serve the secure version of the site over a different domain.

Your url being insecure means Ghost is still allowed to serve the insecure version, and this conflicts with your redirect:

return 301 https://$server_name$request_uri;

I'm closing this as I believe it is a configuration issue, rather than a bug. If you are able to provide evidence that there is a bug then we'll reopen it and @jillesme has already kindly offered to fix it for you.

@ErisDS Does Ghost support SSL only blogs?

I tried yesterday but received the "too many redirects" error this ticket describes. The only way the blog would work was to have url as http (which nginx redirects when ever hit) and urlSSL as expected. This does work but sharing links etc. always have to be redirected before they're resolved.

Is there a way to only use urlSSL throughout the app?
Thanks

Late to the party, but this is the first hit for 'ghost too many redirects'.

You need to set an X-Forwarded-Proto header so Ghost knows it's being hit via SSL despite being behind a reverse proxy.

Chris is correct. Here is a working Nginx configuration:

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://127.0.0.1:2368;
}

If you're reading this, check out https://github.com/TryGhost/Ghost/issues/2796

@bbixler Thank you a lot, it has been worked. But why it could be works

@bbixler Thx a lot, You saved my life.

This needs to be in the docs. I lost 5 hours of my life on this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattferderer picture mattferderer  路  4Comments

jaguart picture jaguart  路  3Comments

hjzheng picture hjzheng  路  4Comments

HenryMarshall picture HenryMarshall  路  4Comments

krokofant picture krokofant  路  3Comments