Path-based reverse proxy for "under development" Rails app on Nginx

Asked 3 months ago, Updated 3 months ago, 6 views

I'm thinking of doing path-based reverse proxy to share an environment where only 80 ports are open to the outside world with multiple developers.As it is a development environment, the server is WEBrick.

Connect to http://server/develop1 to localhost:3000,
Connect to http://server/develop2 to localhost:3001,

I want to set it to fly.

When I asked @matsuu on Twitter,

https://gist.github.com/matsuu/c4b5532075c95401fb9e

I was told that it might be possible to set it up in .
When I tried it, I could connect to the Rails app I posted on WEBrick by accessing http://server/devel1, but the application is not working properly.
If you look at the Nginx error log, you can see

March 24, 2015 23:26:35 [error] 7627#0:*2 open()"/usr/share/nginx/html/rails/info/properties" failed (2: No such file or directory), client: 126.185.134.71, server:localhost, request:"GET/info.119"GET.hosts.119/hosts.hops,119"GET/1/host.hosts.hosts.hops.119

The reason seems to be that the request in the Rails app is pointing to ROOT.
I think the app needs to set something up, but I don't want to do much to move it in this environment.
What should I do?

ruby-on-rails nginx

2022-09-30 11:51

2 Answers

If that's the case, I'll use virtualhost, but if you want to use reverse proxy on a path basis, This question will be helpful.

 location/foo{
    rewrite^/foo$https://example.net/foo/ permanent;
    rewrite^/foo/(.*)/$1break;
    proxy_pass http://localhost:9000;
}

However, if it's based on pass, it would be troublesome to use the absolute pass in the app (although there's no problem if you think about it), so I think I can recommend it.


2022-09-30 11:51

Depending on the rails version,
ActionController::AbstractRequest.relative_url_root='/foo'
Or
ActionController::Base.relative_url_root='/foo'
How about setting something like this?


2022-09-30 11:51

If you have any answers or tips


© 2023 OneMinuteCode. All rights reserved.