Setup as subfolder on Heroku

Hello everyone! Nice to join your community!
I am trying to set up the ghost as a subfolder.

What I have

Ruby on Rails server

Hosted on Heroku. I am not sure if I can share its URL, so let it be rails-server. herokuapp. com (sorry for spaces, i’ve done this to aviod forum 3 urls per post limit). In front of Ruby on Rails server, I have an Nginx server with the following config:

    server {
        listen <%= ENV["PORT"] %>;
        server_name _;
        keepalive_timeout 5;
        client_header_buffer_size 12k;

        location /blog/ {
            client_max_body_size 10G;
            resolver 1.1.1.1 8.8.8.8;
            proxy_pass https://ghost-blog.herokuapp.com/;
            proxy_redirect off;
            proxy_set_header Host rails-server.herokuapp.com;
            proxy_set_header X-Forwarded-Host rails-server.herokuapp.com;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto https;
        }

        location / {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;
            proxy_pass http://app_server;
            client_max_body_size 15m;
        }
    }

Ghost server

Running as node application on another Heroku server. Let’s assume that the server with ghost is located at ghost-blog. herokuapp. com. Config was originated from here: GitHub - cobyism/ghost-on-heroku: One-button Heroku deploy for the Ghost blogging platform.. The only two small changes I made are the upgrade of ghost version to 2.2.0 (i will explain why 2.2.0 a bit later) and ‘url’ in config is https ://rails-server. herokuapp .com/blog.

Problematic

This setup is working very fine(I mean all is OK - site browsing, posts creating, email sending and so on) except for one thing. When I invite a user and he visits an invitation URL he sees a blank screen. With the following errors in the developer console.


After some investigations, I have found the following issue: when I try to visit the welcome post URL https ://rails-server.herokuapp.com/blog/welcome/ all is OK. But when I visit https ://rails-server.herokuapp.com/blog/welcome it redirects me to https ://rails-server.herokuapp.com/welcome. Same issue with the assets. When I visit links (with asset loading errors) in the console I see that all of that links are forwarding me to the https:// rails-server.herokuapp .com/path-to-the-asset (without /blog). And I think that it’s wired each to

And last thing: why I am v2.2.0: because at higher versions I have the errors I described in this GitHub issue.
Does anybody have some ideas about what to do? I am struggling for a few days on this issue and will appreciate any help.

Sorry again for spaces in the URLs.

Wow. Looks like the setup like mine is really used very rarely if nobody knows what happens :face_with_head_bandage:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.