Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to subdirectory #378

Open
LouisKottmann opened this issue Aug 14, 2014 · 8 comments
Open

Deploy to subdirectory #378

LouisKottmann opened this issue Aug 14, 2014 · 8 comments

Comments

@LouisKottmann
Copy link

Hello,

I'm trying to make a solid docker container for kandan and I'm stuck at trying to run kandan in a subdirectory.

I got it all working as root application

RAILS_ENV=production bundle exec thin start

I load up localhost:3000

Everything works fine


When I run instead:

RAILS_RELATIVE_URL_ROOT='/kandan' RAILS_ENV=production bundle exec thin start

I load up localhost:3000/kandan

I get an error: The page you were looking for doesn't exist (404)

Any help appreciated!

@tyleraland
Copy link

I was having similar trouble using apache as a proxy and redirecting to kandan with the RAILS_RELATIVE_URL_ROOT as above. In my case, the app processed the request, but the URL it returned was "my_site.com/users/sign_in" when it should have been "my_site.com/kandan/users/sign_in". After trying many things on the apache end to fix the URL, I'm left thinking it's a Kandan issue.

@LouisKottmann
Copy link
Author

@tyleraland I tried so many things, for 2 straight days actually, nothing does it. I tried:

  • tweakings to nginx
  • adding --prefix=/kandan to thin start
  • RAILS_RELATIVE_URL_ROOT="/kandan"
  • map Kandan::Application.config.relative_url_root before run Rack::URLMap... in config.ru
  • tweaking the content of run Rack::URLMap... in config.ru
  • scope "/kandan" in routes.rb
  • config.relative_url_root = "/kandan" in production.rb
  • many combinations of all the above

Nothing really worked, I got partial stuff working like the account menu and login/main page with assets loading (need to set config.serve_static_assets = true in production.rb).

But Faye never understood to make its POST requests to /kandan/remote/faye instead of /remote/faye, I never got the /channels to get the correct route, and lots of other stuff. This is a nightmare.

Furthermore, there hasn't been any activity since May this year, long holidays?

@tyleraland
Copy link

I've resigned to asking my local network administrator to add a second DNS entry pointing to the existing server, then use it to uniquely identify via ServerName in apache, which seems to work fine (no subdirectories...)

Would love to see this fixed :)

@LouisKottmann
Copy link
Author

@tyleraland can you explain that procedure in more details? I'm trying to keep SSL on at the same time..

I asked on stackoverflow (here)

@tyleraland
Copy link

With the caveat that I'm still testing/configuring... (and that this is apache, not some sexy ruby app)

I've asked my local network admin to add a second DNS entry, by a different name, pointing to the IP of the apache server. Incoming requests to that server see the URL request and hand it off to the correct virtualhost, identified by ServerName in the virtualhosts block.

In my /etc/apache2/sites-available/kandan:

# Capture all HTTP traffic and rewrite it to use HTTPS
<VirtualHost *:80>
    # redirect user to https
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

# Capture all HTTPS traffic to my_kandan_site.com.
<VirtualHost *:443>
    ServerName my_kandan_site.com
    # Redirect it to my local kandan app
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

SSLEngine on
SSLCertificateFile /etc/ssl/certs/InCommon.pem
SSLCertificateKeyFile /etc/ssl/private/my_kandan_site.key

Kandan just runs, without special modifications, with "bundle exec thin start"

@scouttyg
Copy link
Member

Have you seen #370 for docker support? I haven't pulled it in yet as I haven't tested it, but that might be a good start. Looks like @tyleraland might have more experience setting this up under the environment you want however.

@LouisKottmann
Copy link
Author

@scouttyg I don't see how #370 helps me to run kandan at http://mysite.com/kandan, did I miss something?

@JialuZhang
Copy link

@tyleraland

In your configuration,

<VirtualHost *:443>
    ServerName my_kandan_site.com
    # Redirect it to my local kandan app
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/

There should be a line to close the <VirtualHost *:443>. Otherwise, this is a syntax-related misconfiguration.

The correct one would be:

# Capture all HTTP traffic and rewrite it to use HTTPS
<VirtualHost *:80>
    # redirect user to https
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>

# Capture all HTTPS traffic to my_kandan_site.com.
<VirtualHost *:443>
    ServerName my_kandan_site.com
    # Redirect it to my local kandan app
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
</VirtualHost>

SSLEngine on
SSLCertificateFile /etc/ssl/certs/InCommon.pem
SSLCertificateKeyFile /etc/ssl/private/my_kandan_site.key

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants