开发者

Is this a Sinatra config issue, or an Apache config issue?

开发者 https://www.devze.com 2023-01-30 06:52 出处:网络
I haven\'t decided if this is an Apache issue, or a Sinatra issue, basically, we have a bunch of little apps running on a single server, we deploy them with just built-in webrick instances and use apa

I haven't decided if this is an Apache issue, or a Sinatra issue, basically, we have a bunch of little apps running on a single server, we deploy them with just built-in webrick instances and use apache to re-route those requests by subdomain to the right port. I am using gollum which is a sinatra app with a git persistence layer, but I am getting an unexpected app routing when it redirects (after edit action). I'm not sure if I can fix this by passing a startup option to Sinatra, or by configuring in the virtual host declaration for the app a rewrite rule. Please in your answer include which option you think is best and an example of how it might be accomplished. Thanks,

# apache virtualhost declaration
<VirtualHost *:80>
  ServerName wiki.domain.com
  DocumentRoot "/var/www/html"

  ProxyPass / http://localhost:3006
  ProxyPassReverse / http://localhost:3006
</VirtualHost>

开发者_运维百科resolves with sinatra fine for GETs, eg

wiki.domain.com/Home

but fails on sinatra redirect

# expected
wiki.domain.com/Home

# actual
wiki.domain.com:3006/Home

and here is the Sinatra action (source: https://github.com/github/gollum/blob/master/lib/gollum/frontend/app.rb )

post '/edit/*' do
  name   = params[:splat].first
  wiki   = Gollum::Wiki.new(settings.gollum_path)
  page   = wiki.page(name)
  format = params[:format].intern
  name   = params[:rename] if params[:rename]

  wiki.update_page(page, name, format, params[:content], commit_message)

  redirect "/#{CGI.escape(Gollum::Page.cname(name))}"
end


It’s a long shot, but perhaps the URLs in the ProxyPass directives need to have a trailing /? That’s how it is in the documentation, and I got some strange entries in error.log without them.

0

精彩评论

暂无评论...
验证码 换一张
取 消