Specifically, Dreamhost. I''m trying to figure out how to get this to work the standard dispatch.cgi or dispatch.fcgi setup. I''ve been using the instructions that Magnus sent out when he first announced his plan for Camping 2.0, but they either no longer apply, or I''m an edge case. I''ve been pushing at it for a while, just to get it working on CGI, and the problem seems to be that dispatch.cgi doesn''t end in .ru! Rack tries to "require ''dispatch.cgi''", which is no good. Here''s my dispatch.cgi, with names changed to protect the innocent: ================= #!/usr/bin/env rackup ENV[''GEM_PATH''] = ''/path/to/local/gems'' ENV[''GEM_HOME''] = ''/path/to/local/gems'' ENV[''FORCE_ROOT'']=1.to_s Dir.chdir ''/path/to/app'' require ''app'' App::Models::Base.establish_connection :adapter => ''sqlite3'', :database => ''app.db'' App.create run App ============ And the error trace, as reported through apache''s error logs: /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'': no such file to load -- dispatch.cgi (LoadError) from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' from /usr/lib/ruby/gems/1.8/gems/rack-0.3.0/bin/rackup:92 from /usr/bin/rackup:19:in `load'' from /usr/bin/rackup:19 Premature end of script headers: dispatch.cgi I''m still trying to get my head around the new Rack setup, the problem might be some simple naivete on my part. Anyone have any ideas how I can push forward? Thanks, Eric
Some progress: I put most of the code from dispatch.cgi into a "config.ru", and dispatch.cgi now uses backticks to literally call ''/usr/bin/env rackup''. This works, yet now calls to "/" redirect to "/dispatch.cgi/" (this is truly the path in my browser location bar), and it messes with my routing. ==== config.ru =====Dir.chdir ''/path/to/app'' require ''app'' App::Models::Base.establish_connection :adapter => ''sqlite3'', :database => ''app.db'' App.create run App ==== dispatch.cgi ===#!/usr/bin/ruby ENV[''GEM_PATH''] = ''/path/to/gems'' ENV[''GEM_HOME''] = ''/path/to/gems'' puts `/usr/bin/env rackup` And now I am definitely giving up for the night and sleeping. Any ideas? Thanks, Eric On Fri, Jul 11, 2008 at 1:06 AM, Eric Mill <kprojection at gmail.com> wrote:> Specifically, Dreamhost. I''m trying to figure out how to get this to > work the standard dispatch.cgi or dispatch.fcgi setup. I''ve been > using the instructions that Magnus sent out when he first announced > his plan for Camping 2.0, but they either no longer apply, or I''m an > edge case. > > I''ve been pushing at it for a while, just to get it working on CGI, > and the problem seems to be that dispatch.cgi doesn''t end in .ru! > Rack tries to "require ''dispatch.cgi''", which is no good. Here''s my > dispatch.cgi, with names changed to protect the innocent: > > =================> > #!/usr/bin/env rackup > > ENV[''GEM_PATH''] = ''/path/to/local/gems'' > ENV[''GEM_HOME''] = ''/path/to/local/gems'' > ENV[''FORCE_ROOT'']=1.to_s > > Dir.chdir ''/path/to/app'' > > require ''app'' > App::Models::Base.establish_connection :adapter => ''sqlite3'', > :database => ''app.db'' > App.create > > run App > > ============> > And the error trace, as reported through apache''s error logs: > > /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `gem_original_require'': no such file to load -- dispatch.cgi > (LoadError) > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' > from /usr/lib/ruby/gems/1.8/gems/rack-0.3.0/bin/rackup:92 > from /usr/bin/rackup:19:in `load'' > from /usr/bin/rackup:19 > Premature end of script headers: dispatch.cgi > > I''m still trying to get my head around the new Rack setup, the problem > might be some simple naivete on my part. Anyone have any ideas how I > can push forward? > > Thanks, > Eric >
What about dropping the idea of config.ru and just create a dispatch.cgi like this? #!/usr/bin/env ruby require ''app'' Rack::Handler::CGI.run(App) On Fri, Jul 11, 2008 at 7:33 AM, Eric Mill <kprojection at gmail.com> wrote:> Some progress: I put most of the code from dispatch.cgi into a > "config.ru", and dispatch.cgi now uses backticks to literally call > ''/usr/bin/env rackup''. This works, yet now calls to "/" redirect to > "/dispatch.cgi/" (this is truly the path in my browser location bar), > and it messes with my routing. > > ==== config.ru =====> Dir.chdir ''/path/to/app'' > require ''app'' > App::Models::Base.establish_connection :adapter => ''sqlite3'', > :database => ''app.db'' > App.create > run App > > ==== dispatch.cgi ===> #!/usr/bin/ruby > ENV[''GEM_PATH''] = ''/path/to/gems'' > ENV[''GEM_HOME''] = ''/path/to/gems'' > puts `/usr/bin/env rackup` > > > And now I am definitely giving up for the night and sleeping. Any ideas? > > Thanks, > Eric > > On Fri, Jul 11, 2008 at 1:06 AM, Eric Mill <kprojection at gmail.com> wrote: > > Specifically, Dreamhost. I''m trying to figure out how to get this to > > work the standard dispatch.cgi or dispatch.fcgi setup. I''ve been > > using the instructions that Magnus sent out when he first announced > > his plan for Camping 2.0, but they either no longer apply, or I''m an > > edge case. > > > > I''ve been pushing at it for a while, just to get it working on CGI, > > and the problem seems to be that dispatch.cgi doesn''t end in .ru! > > Rack tries to "require ''dispatch.cgi''", which is no good. Here''s my > > dispatch.cgi, with names changed to protect the innocent: > > > > =================> > > > #!/usr/bin/env rackup > > > > ENV[''GEM_PATH''] = ''/path/to/local/gems'' > > ENV[''GEM_HOME''] = ''/path/to/local/gems'' > > ENV[''FORCE_ROOT'']=1.to_s > > > > Dir.chdir ''/path/to/app'' > > > > require ''app'' > > App::Models::Base.establish_connection :adapter => ''sqlite3'', > > :database => ''app.db'' > > App.create > > > > run App > > > > ============> > > > And the error trace, as reported through apache''s error logs: > > > > /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > > `gem_original_require'': no such file to load -- dispatch.cgi > > (LoadError) > > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in > `require'' > > from /usr/lib/ruby/gems/1.8/gems/rack-0.3.0/bin/rackup:92 > > from /usr/bin/rackup:19:in `load'' > > from /usr/bin/rackup:19 > > Premature end of script headers: dispatch.cgi > > > > I''m still trying to get my head around the new Rack setup, the problem > > might be some simple naivete on my part. Anyone have any ideas how I > > can push forward? > > > > Thanks, > > Eric > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-- Magnus Holm -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20080714/3982007c/attachment.html>
Actually, that is what I''m doing now, and I''m still seeing the same behavior -- redirects preface the URL with "/dispatch.cgi/", and the Camping cookies are valid under path "/dispatch.cgi/". I have another camping app on the same account, that uses Camping 1.5.180, and when I first tried it under CGI I didn''t get this behavior. I''m using the same .htaccess, too. -- Eric On Mon, Jul 14, 2008 at 4:44 AM, Magnus Holm <judofyr at gmail.com> wrote:> What about dropping the idea of config.ru and just create a dispatch.cgi > like this? > > #!/usr/bin/env ruby > require ''app'' > Rack::Handler::CGI.run(App) > > On Fri, Jul 11, 2008 at 7:33 AM, Eric Mill <kprojection at gmail.com> wrote: >> >> Some progress: I put most of the code from dispatch.cgi into a >> "config.ru", and dispatch.cgi now uses backticks to literally call >> ''/usr/bin/env rackup''. This works, yet now calls to "/" redirect to >> "/dispatch.cgi/" (this is truly the path in my browser location bar), >> and it messes with my routing. >> >> ==== config.ru =====>> Dir.chdir ''/path/to/app'' >> require ''app'' >> App::Models::Base.establish_connection :adapter => ''sqlite3'', >> :database => ''app.db'' >> App.create >> run App >> >> ==== dispatch.cgi ===>> #!/usr/bin/ruby >> ENV[''GEM_PATH''] = ''/path/to/gems'' >> ENV[''GEM_HOME''] = ''/path/to/gems'' >> puts `/usr/bin/env rackup` >> >> >> And now I am definitely giving up for the night and sleeping. Any ideas? >> >> Thanks, >> Eric >> >> On Fri, Jul 11, 2008 at 1:06 AM, Eric Mill <kprojection at gmail.com> wrote: >> > Specifically, Dreamhost. I''m trying to figure out how to get this to >> > work the standard dispatch.cgi or dispatch.fcgi setup. I''ve been >> > using the instructions that Magnus sent out when he first announced >> > his plan for Camping 2.0, but they either no longer apply, or I''m an >> > edge case. >> > >> > I''ve been pushing at it for a while, just to get it working on CGI, >> > and the problem seems to be that dispatch.cgi doesn''t end in .ru! >> > Rack tries to "require ''dispatch.cgi''", which is no good. Here''s my >> > dispatch.cgi, with names changed to protect the innocent: >> > >> > =================>> > >> > #!/usr/bin/env rackup >> > >> > ENV[''GEM_PATH''] = ''/path/to/local/gems'' >> > ENV[''GEM_HOME''] = ''/path/to/local/gems'' >> > ENV[''FORCE_ROOT'']=1.to_s >> > >> > Dir.chdir ''/path/to/app'' >> > >> > require ''app'' >> > App::Models::Base.establish_connection :adapter => ''sqlite3'', >> > :database => ''app.db'' >> > App.create >> > >> > run App >> > >> > ============>> > >> > And the error trace, as reported through apache''s error logs: >> > >> > /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in >> > `gem_original_require'': no such file to load -- dispatch.cgi >> > (LoadError) >> > from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in >> > `require'' >> > from /usr/lib/ruby/gems/1.8/gems/rack-0.3.0/bin/rackup:92 >> > from /usr/bin/rackup:19:in `load'' >> > from /usr/bin/rackup:19 >> > Premature end of script headers: dispatch.cgi >> > >> > I''m still trying to get my head around the new Rack setup, the problem >> > might be some simple naivete on my part. Anyone have any ideas how I >> > can push forward? >> > >> > Thanks, >> > Eric >> > >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list > > > > -- > Magnus Holm > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >
Could you show us the .htaccess please? :)
Also, is it possible that you could simply rename dispatch.cgi to something like ''appname'' and use htaccess to grant that file cgi execution type permissions? Or does this need to be on the root of a domain?
can you please try adding to htaccess SetEnv SCRIPT_NAME /path/to/app Assuming your dispatch is in /path/to/app/dispatch.cgi Let us know what happens!
No wait, this is even better, at the end of your RewriteRule, put: [env=SCRIPT_NAME:/path/to/app] Let us know what happens!
I''m not able to get this working, I can''t seem to affect the environment, either using the SetEnv approach, or by including that at the end of RewriteRule. How does Camping use the env in forming its understanding of its base URI? Forming URLs using the "R" method does not pre-pend "/dispatch.cgi/", but calling Redirect does. And as I said earlier, session cookies are set for the path "/dispatch.cgi/". I''m continuing to investigate... -- Eric On Mon, Jul 14, 2008 at 9:22 AM, Bluebie, Jenna <blueberry at creativepony.com> wrote:> No wait, this is even better, at the end of your RewriteRule, put: > > [env=SCRIPT_NAME:/path/to/app] > > Let us know what happens! > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >
R won''t add the root path (it''s a feature, not a bug). Camping (and Rack) assumes that SCRIPT_NAME will contain the root path. If you can''t change it in Apache, I guess you could add a middleware: class ScriptNameFixer def initialize(app) @app = app end def call(env) env["SCRIPT_NAME"] = "/your/path" @app.call(env) end end Could you post your .htaccess? There must be a way to do this properly in Apache! On Mon, Jul 14, 2008 at 6:14 PM, Eric Mill <kprojection at gmail.com> wrote:> I''m not able to get this working, I can''t seem to affect the > environment, either using the SetEnv approach, or by including that at > the end of RewriteRule. How does Camping use the env in forming its > understanding of its base URI? > > Forming URLs using the "R" method does not pre-pend "/dispatch.cgi/", > but calling Redirect does. And as I said earlier, session cookies are > set for the path "/dispatch.cgi/". > > I''m continuing to investigate... > > -- Eric > > On Mon, Jul 14, 2008 at 9:22 AM, Bluebie, Jenna > <blueberry at creativepony.com> wrote: > > No wait, this is even better, at the end of your RewriteRule, put: > > > > [env=SCRIPT_NAME:/path/to/app] > > > > Let us know what happens! > > _______________________________________________ > > Camping-list mailing list > > Camping-list at rubyforge.org > > http://rubyforge.org/mailman/listinfo/camping-list > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-- Magnus Holm -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/camping-list/attachments/20080714/ce63a64b/attachment.html>
I really do think we should build in the SCRIPT_URL || SCRIPT_NAME thingo. This is going to be a relatively common situation. Totally worth the bytes.
Julik Tarkhanov
2008-Jul-14 23:20 UTC
Troubleshooting: Camping 2.0 on CGI on a shared host
On Jul 15, 2008, at 12:58 AM, Bluebie, Jenna wrote:> I really do think we should build in the SCRIPT_URL || SCRIPT_NAME > thingo. This is going to be a relatively common situation. Totally > worth the bytes.You might, but this is a can of worms. See, right now for example, if you need to mount Camping on all root URLs but you still want to handle static files via frontent web servers you have a problem, because an FCGI mount "swallows" all URLs inside it. I didn''t manage (with the current setup, not with Camping 2) to both mount a rooted app and handle the files bypassing it, exactly because in FCGI-parlance the "mount" of the FCGI dispatcher is the SCRIPT_NAME. Dunno about "thingos" but a clean solution would be welcome (also Rack currently advises the user to _write_ a hack for Lighttpd for broken SCRIPT_NAME - can''t even tell how silly that is).
We are talking about cgi here, not fast cgi. Specifically CGI''s interactions with mod_rewrite in apache.
My .htaccess is pretty basic, I think: AddHandler fastcgi-script .fcgi Options +FollowSymLinks +ExecCGI RewriteEngine On RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.cgi [QSA,L] Anything out of the ordinary there? -- Eric On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna <blueberry at creativepony.com> wrote:> We are talking about cgi here, not fast cgi. Specifically CGI''s interactions > with mod_rewrite in apache. > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >
Bluebie -- I tried doing this with FastCGI with the same settings (changed .htaccess to point to dispatch.fcgi, changed dispatch file to use Rack::Handler::FastCGI.run, got the exact same results. FastCGI will also suffer from these bugs. -- Eric On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna <blueberry at creativepony.com> wrote:> We are talking about cgi here, not fast cgi. Specifically CGI''s interactions > with mod_rewrite in apache. > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >
This "bug" is actually Apache''s fault. The problem occurs when you use mod_rewrite to hide that you''re using dispatch.cgi. When you use "RewriteRule ^(.*)$ dispatch.cgi" the following happens: * SCRIPT_NAME is set to /dispatch.cgi (since that''s the actual script which gets ran) * REDIRECT_SCRIPT_NAME is set to whatever SCRIPT_NAME was before * PATH_INFO is emptied I''ve also tested this on 1.5 and it has the same problem. However, if you use server/fastcgi.rb (not Rack as I''ve been testing with) you can set the ENV[''FORCE_ROOT''] to 1 and it will re-set SCRIPT_NAME and PATH_INFO using REQUEST_URI, which will (partly) solve the problem. Right now, we have no FORCE_ROOT in Rack, but here''s a simple fix: * Change .htaccess to "RewriteRule ^(.*)$ dispatch.cgi/$1" (You might need to drop to slash). * Add a middleware which sets SCRIPT_NAME to REDIRECT_SCRIPT_NAME (http://pastie.org/235062) This isn''t really our problem, but rather Apache (which should be able to alias CGI-scripts with the correct headers). It probably won''t happen, so I guess we have to add some nasty hacks into Rack. I haven''t tried this on any other servers (LightTPD/Nginx), but as long as there is no URL-rewriting (I know LightTPD can do it with FastCGI) it''s probably no problem (maybe not even with, if it''s smart enough). Here is a simple app which shows @env (and works on both 1.5 and 2.0): http://pastie.org/235078. It would be great if you could test it on different setups and see which requires special treatment. Check out the Rack-spec for how the variables should be set: http://rack.rubyforge.org/doc/files/SPEC.html On Wed, Jul 16, 2008 at 5:07 PM, Eric Mill <kprojection at gmail.com> wrote:> > Bluebie -- I tried doing this with FastCGI with the same settings > (changed .htaccess to point to dispatch.fcgi, changed dispatch file to > use Rack::Handler::FastCGI.run, got the exact same results. FastCGI > will also suffer from these bugs. > > -- Eric > > On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna > <blueberry at creativepony.com> wrote: > > We are talking about cgi here, not fast cgi. Specifically CGI''s interactions > > with mod_rewrite in apache. > > _______________________________________________ > > Camping-list mailing list > > Camping-list at rubyforge.org > > http://rubyforge.org/mailman/listinfo/camping-list > > > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list-- Magnus Holm
Magnus, this is terrific information, thank you for looking into this. I''m trying to follow your example - you use ApacheFixer to make a "TestingFixed" class, but never use that class anywhere else. Do you mean for the lines in dispatch.* to use "TestingFixed" instead of "Testing"? I''m trying to use this to resolve my problems as we speak, Eric On Wed, Jul 16, 2008 at 5:08 PM, Magnus Holm <judofyr at gmail.com> wrote:> This "bug" is actually Apache''s fault. The problem occurs when you use > mod_rewrite to hide that you''re using dispatch.cgi. When you use > "RewriteRule ^(.*)$ dispatch.cgi" the following happens: > > * SCRIPT_NAME is set to /dispatch.cgi (since that''s the actual script > which gets ran) > * REDIRECT_SCRIPT_NAME is set to whatever SCRIPT_NAME was before > * PATH_INFO is emptied > > I''ve also tested this on 1.5 and it has the same problem. However, if > you use server/fastcgi.rb (not Rack as I''ve been testing with) you can > set the ENV[''FORCE_ROOT''] to 1 and it will re-set SCRIPT_NAME and > PATH_INFO using REQUEST_URI, which will (partly) solve the problem. > > Right now, we have no FORCE_ROOT in Rack, but here''s a simple fix: > > * Change .htaccess to "RewriteRule ^(.*)$ dispatch.cgi/$1" (You might > need to drop to slash). > * Add a middleware which sets SCRIPT_NAME to REDIRECT_SCRIPT_NAME > (http://pastie.org/235062) > > This isn''t really our problem, but rather Apache (which should be able > to alias CGI-scripts with the correct headers). It probably won''t > happen, so I guess we have to add some nasty hacks into Rack. > > I haven''t tried this on any other servers (LightTPD/Nginx), but as > long as there is no URL-rewriting (I know LightTPD can do it with > FastCGI) it''s probably no problem (maybe not even with, if it''s smart > enough). > > Here is a simple app which shows @env (and works on both 1.5 and 2.0): > http://pastie.org/235078. It would be great if you could test it on > different setups and see which requires special treatment. Check out > the Rack-spec for how the variables should be set: > http://rack.rubyforge.org/doc/files/SPEC.html > > On Wed, Jul 16, 2008 at 5:07 PM, Eric Mill <kprojection at gmail.com> wrote: >> >> Bluebie -- I tried doing this with FastCGI with the same settings >> (changed .htaccess to point to dispatch.fcgi, changed dispatch file to >> use Rack::Handler::FastCGI.run, got the exact same results. FastCGI >> will also suffer from these bugs. >> >> -- Eric >> >> On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna >> <blueberry at creativepony.com> wrote: >> > We are talking about cgi here, not fast cgi. Specifically CGI''s interactions >> > with mod_rewrite in apache. >> > _______________________________________________ >> > Camping-list mailing list >> > Camping-list at rubyforge.org >> > http://rubyforge.org/mailman/listinfo/camping-list >> > >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list > > > > -- > Magnus Holm > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >
Simply replace Testing with TestingFixed in dispatch.cgi:11 and dispatch.fcgi:13 to see the diffenrence :-) On Wed, Jul 16, 2008 at 11:28 PM, Eric Mill <kprojection at gmail.com> wrote:> Magnus, this is terrific information, thank you for looking into this. > > I''m trying to follow your example - you use ApacheFixer to make a > "TestingFixed" class, but never use that class anywhere else. Do you > mean for the lines in dispatch.* to use "TestingFixed" instead of > "Testing"? > > I''m trying to use this to resolve my problems as we speak, > Eric > > On Wed, Jul 16, 2008 at 5:08 PM, Magnus Holm <judofyr at gmail.com> wrote: >> This "bug" is actually Apache''s fault. The problem occurs when you use >> mod_rewrite to hide that you''re using dispatch.cgi. When you use >> "RewriteRule ^(.*)$ dispatch.cgi" the following happens: >> >> * SCRIPT_NAME is set to /dispatch.cgi (since that''s the actual script >> which gets ran) >> * REDIRECT_SCRIPT_NAME is set to whatever SCRIPT_NAME was before >> * PATH_INFO is emptied >> >> I''ve also tested this on 1.5 and it has the same problem. However, if >> you use server/fastcgi.rb (not Rack as I''ve been testing with) you can >> set the ENV[''FORCE_ROOT''] to 1 and it will re-set SCRIPT_NAME and >> PATH_INFO using REQUEST_URI, which will (partly) solve the problem. >> >> Right now, we have no FORCE_ROOT in Rack, but here''s a simple fix: >> >> * Change .htaccess to "RewriteRule ^(.*)$ dispatch.cgi/$1" (You might >> need to drop to slash). >> * Add a middleware which sets SCRIPT_NAME to REDIRECT_SCRIPT_NAME >> (http://pastie.org/235062) >> >> This isn''t really our problem, but rather Apache (which should be able >> to alias CGI-scripts with the correct headers). It probably won''t >> happen, so I guess we have to add some nasty hacks into Rack. >> >> I haven''t tried this on any other servers (LightTPD/Nginx), but as >> long as there is no URL-rewriting (I know LightTPD can do it with >> FastCGI) it''s probably no problem (maybe not even with, if it''s smart >> enough). >> >> Here is a simple app which shows @env (and works on both 1.5 and 2.0): >> http://pastie.org/235078. It would be great if you could test it on >> different setups and see which requires special treatment. Check out >> the Rack-spec for how the variables should be set: >> http://rack.rubyforge.org/doc/files/SPEC.html >> >> On Wed, Jul 16, 2008 at 5:07 PM, Eric Mill <kprojection at gmail.com> wrote: >>> >>> Bluebie -- I tried doing this with FastCGI with the same settings >>> (changed .htaccess to point to dispatch.fcgi, changed dispatch file to >>> use Rack::Handler::FastCGI.run, got the exact same results. FastCGI >>> will also suffer from these bugs. >>> >>> -- Eric >>> >>> On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna >>> <blueberry at creativepony.com> wrote: >>> > We are talking about cgi here, not fast cgi. Specifically CGI''s interactions >>> > with mod_rewrite in apache. >>> > _______________________________________________ >>> > Camping-list mailing list >>> > Camping-list at rubyforge.org >>> > http://rubyforge.org/mailman/listinfo/camping-list >>> > >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >> >> >> >> -- >> Magnus Holm >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-- Magnus Holm
Unfortunately this isn''t working. I''m checking my ENV and REDIRECT_SCRIPT_NAME isn''t set to anything. I''m using the Rack spec to try to figure out an alternative. Right now, requests to "/" go to a Camping error page which says "/index.html not found!" and requests to "/login" (which should go to a different controller) says "/login.html not found!". PATH_INFO has been set to "/login.html" in this case. I also tried setting SCRIPT_NAME to be whatever REQUEST_URI is, but this has the same effect as using the REDIRECT_SCRIPT_NAME approach. Continuing to investigate, Eric On Wed, Jul 16, 2008 at 5:31 PM, Magnus Holm <judofyr at gmail.com> wrote:> Simply replace Testing with TestingFixed in dispatch.cgi:11 and > dispatch.fcgi:13 to see the diffenrence :-) > > On Wed, Jul 16, 2008 at 11:28 PM, Eric Mill <kprojection at gmail.com> wrote: >> Magnus, this is terrific information, thank you for looking into this. >> >> I''m trying to follow your example - you use ApacheFixer to make a >> "TestingFixed" class, but never use that class anywhere else. Do you >> mean for the lines in dispatch.* to use "TestingFixed" instead of >> "Testing"? >> >> I''m trying to use this to resolve my problems as we speak, >> Eric >> >> On Wed, Jul 16, 2008 at 5:08 PM, Magnus Holm <judofyr at gmail.com> wrote: >>> This "bug" is actually Apache''s fault. The problem occurs when you use >>> mod_rewrite to hide that you''re using dispatch.cgi. When you use >>> "RewriteRule ^(.*)$ dispatch.cgi" the following happens: >>> >>> * SCRIPT_NAME is set to /dispatch.cgi (since that''s the actual script >>> which gets ran) >>> * REDIRECT_SCRIPT_NAME is set to whatever SCRIPT_NAME was before >>> * PATH_INFO is emptied >>> >>> I''ve also tested this on 1.5 and it has the same problem. However, if >>> you use server/fastcgi.rb (not Rack as I''ve been testing with) you can >>> set the ENV[''FORCE_ROOT''] to 1 and it will re-set SCRIPT_NAME and >>> PATH_INFO using REQUEST_URI, which will (partly) solve the problem. >>> >>> Right now, we have no FORCE_ROOT in Rack, but here''s a simple fix: >>> >>> * Change .htaccess to "RewriteRule ^(.*)$ dispatch.cgi/$1" (You might >>> need to drop to slash). >>> * Add a middleware which sets SCRIPT_NAME to REDIRECT_SCRIPT_NAME >>> (http://pastie.org/235062) >>> >>> This isn''t really our problem, but rather Apache (which should be able >>> to alias CGI-scripts with the correct headers). It probably won''t >>> happen, so I guess we have to add some nasty hacks into Rack. >>> >>> I haven''t tried this on any other servers (LightTPD/Nginx), but as >>> long as there is no URL-rewriting (I know LightTPD can do it with >>> FastCGI) it''s probably no problem (maybe not even with, if it''s smart >>> enough). >>> >>> Here is a simple app which shows @env (and works on both 1.5 and 2.0): >>> http://pastie.org/235078. It would be great if you could test it on >>> different setups and see which requires special treatment. Check out >>> the Rack-spec for how the variables should be set: >>> http://rack.rubyforge.org/doc/files/SPEC.html >>> >>> On Wed, Jul 16, 2008 at 5:07 PM, Eric Mill <kprojection at gmail.com> wrote: >>>> >>>> Bluebie -- I tried doing this with FastCGI with the same settings >>>> (changed .htaccess to point to dispatch.fcgi, changed dispatch file to >>>> use Rack::Handler::FastCGI.run, got the exact same results. FastCGI >>>> will also suffer from these bugs. >>>> >>>> -- Eric >>>> >>>> On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna >>>> <blueberry at creativepony.com> wrote: >>>> > We are talking about cgi here, not fast cgi. Specifically CGI''s interactions >>>> > with mod_rewrite in apache. >>>> > _______________________________________________ >>>> > Camping-list mailing list >>>> > Camping-list at rubyforge.org >>>> > http://rubyforge.org/mailman/listinfo/camping-list >>>> > >>>> _______________________________________________ >>>> Camping-list mailing list >>>> Camping-list at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/camping-list >>> >>> >>> >>> -- >>> Magnus Holm >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >>> >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> > > > > -- > Magnus Holm > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >
Also worth noting is that PATH_INFO isn''t emptied - it''s set to "/" or "/login", the correct request path. -- Eric On Wed, Jul 16, 2008 at 5:40 PM, Eric Mill <kprojection at gmail.com> wrote:> Unfortunately this isn''t working. I''m checking my ENV and > REDIRECT_SCRIPT_NAME isn''t set to anything. I''m using the Rack spec > to try to figure out an alternative. > > Right now, requests to "/" go to a Camping error page which says > "/index.html not found!" and requests to "/login" (which should go to > a different controller) says "/login.html not found!". PATH_INFO has > been set to "/login.html" in this case. > > I also tried setting SCRIPT_NAME to be whatever REQUEST_URI is, but > this has the same effect as using the REDIRECT_SCRIPT_NAME approach. > > Continuing to investigate, > Eric > > On Wed, Jul 16, 2008 at 5:31 PM, Magnus Holm <judofyr at gmail.com> wrote: >> Simply replace Testing with TestingFixed in dispatch.cgi:11 and >> dispatch.fcgi:13 to see the diffenrence :-) >> >> On Wed, Jul 16, 2008 at 11:28 PM, Eric Mill <kprojection at gmail.com> wrote: >>> Magnus, this is terrific information, thank you for looking into this. >>> >>> I''m trying to follow your example - you use ApacheFixer to make a >>> "TestingFixed" class, but never use that class anywhere else. Do you >>> mean for the lines in dispatch.* to use "TestingFixed" instead of >>> "Testing"? >>> >>> I''m trying to use this to resolve my problems as we speak, >>> Eric >>> >>> On Wed, Jul 16, 2008 at 5:08 PM, Magnus Holm <judofyr at gmail.com> wrote: >>>> This "bug" is actually Apache''s fault. The problem occurs when you use >>>> mod_rewrite to hide that you''re using dispatch.cgi. When you use >>>> "RewriteRule ^(.*)$ dispatch.cgi" the following happens: >>>> >>>> * SCRIPT_NAME is set to /dispatch.cgi (since that''s the actual script >>>> which gets ran) >>>> * REDIRECT_SCRIPT_NAME is set to whatever SCRIPT_NAME was before >>>> * PATH_INFO is emptied >>>> >>>> I''ve also tested this on 1.5 and it has the same problem. However, if >>>> you use server/fastcgi.rb (not Rack as I''ve been testing with) you can >>>> set the ENV[''FORCE_ROOT''] to 1 and it will re-set SCRIPT_NAME and >>>> PATH_INFO using REQUEST_URI, which will (partly) solve the problem. >>>> >>>> Right now, we have no FORCE_ROOT in Rack, but here''s a simple fix: >>>> >>>> * Change .htaccess to "RewriteRule ^(.*)$ dispatch.cgi/$1" (You might >>>> need to drop to slash). >>>> * Add a middleware which sets SCRIPT_NAME to REDIRECT_SCRIPT_NAME >>>> (http://pastie.org/235062) >>>> >>>> This isn''t really our problem, but rather Apache (which should be able >>>> to alias CGI-scripts with the correct headers). It probably won''t >>>> happen, so I guess we have to add some nasty hacks into Rack. >>>> >>>> I haven''t tried this on any other servers (LightTPD/Nginx), but as >>>> long as there is no URL-rewriting (I know LightTPD can do it with >>>> FastCGI) it''s probably no problem (maybe not even with, if it''s smart >>>> enough). >>>> >>>> Here is a simple app which shows @env (and works on both 1.5 and 2.0): >>>> http://pastie.org/235078. It would be great if you could test it on >>>> different setups and see which requires special treatment. Check out >>>> the Rack-spec for how the variables should be set: >>>> http://rack.rubyforge.org/doc/files/SPEC.html >>>> >>>> On Wed, Jul 16, 2008 at 5:07 PM, Eric Mill <kprojection at gmail.com> wrote: >>>>> >>>>> Bluebie -- I tried doing this with FastCGI with the same settings >>>>> (changed .htaccess to point to dispatch.fcgi, changed dispatch file to >>>>> use Rack::Handler::FastCGI.run, got the exact same results. FastCGI >>>>> will also suffer from these bugs. >>>>> >>>>> -- Eric >>>>> >>>>> On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna >>>>> <blueberry at creativepony.com> wrote: >>>>> > We are talking about cgi here, not fast cgi. Specifically CGI''s interactions >>>>> > with mod_rewrite in apache. >>>>> > _______________________________________________ >>>>> > Camping-list mailing list >>>>> > Camping-list at rubyforge.org >>>>> > http://rubyforge.org/mailman/listinfo/camping-list >>>>> > >>>>> _______________________________________________ >>>>> Camping-list mailing list >>>>> Camping-list at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>> >>>> >>>> >>>> -- >>>> Magnus Holm >>>> _______________________________________________ >>>> Camping-list mailing list >>>> Camping-list at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/camping-list >>>> >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >>> >> >> >> >> -- >> Magnus Holm >> _______________________________________________ >> Camping-list mailing list >> Camping-list at rubyforge.org >> http://rubyforge.org/mailman/listinfo/camping-list >> >
Julian Tarkhanov
2008-Jul-16 22:03 UTC
Troubleshooting: Camping 2.0 on CGI on a shared host
On 16 jul 2008, at 23:40, Eric Mill wrote:> Unfortunately this isn''t working. I''m checking my ENV and > REDIRECT_SCRIPT_NAME isn''t set to anything. I''m using the Rack spec > to try to figure out an alternative.Rails resolves this somehow, they mount dispatch.fcgi as / dispatch.fcgi and use it as rewrite target.
I think I''ve got it working, with this as the ''fixer'' call: def call(env) env[''SCRIPT_NAME''] = ''/'' env[''PATH_INFO''] = env[''REDIRECT_URL''] @app.call(env) end I think you might have meant REDIRECT_URL and not REDIRECT_SCRIPT_NAME? Thank you Magnus! -- Eric On Wed, Jul 16, 2008 at 5:51 PM, Eric Mill <kprojection at gmail.com> wrote:> Also worth noting is that PATH_INFO isn''t emptied - it''s set to "/" or > "/login", the correct request path. > > -- Eric > > On Wed, Jul 16, 2008 at 5:40 PM, Eric Mill <kprojection at gmail.com> wrote: >> Unfortunately this isn''t working. I''m checking my ENV and >> REDIRECT_SCRIPT_NAME isn''t set to anything. I''m using the Rack spec >> to try to figure out an alternative. >> >> Right now, requests to "/" go to a Camping error page which says >> "/index.html not found!" and requests to "/login" (which should go to >> a different controller) says "/login.html not found!". PATH_INFO has >> been set to "/login.html" in this case. >> >> I also tried setting SCRIPT_NAME to be whatever REQUEST_URI is, but >> this has the same effect as using the REDIRECT_SCRIPT_NAME approach. >> >> Continuing to investigate, >> Eric >> >> On Wed, Jul 16, 2008 at 5:31 PM, Magnus Holm <judofyr at gmail.com> wrote: >>> Simply replace Testing with TestingFixed in dispatch.cgi:11 and >>> dispatch.fcgi:13 to see the diffenrence :-) >>> >>> On Wed, Jul 16, 2008 at 11:28 PM, Eric Mill <kprojection at gmail.com> wrote: >>>> Magnus, this is terrific information, thank you for looking into this. >>>> >>>> I''m trying to follow your example - you use ApacheFixer to make a >>>> "TestingFixed" class, but never use that class anywhere else. Do you >>>> mean for the lines in dispatch.* to use "TestingFixed" instead of >>>> "Testing"? >>>> >>>> I''m trying to use this to resolve my problems as we speak, >>>> Eric >>>> >>>> On Wed, Jul 16, 2008 at 5:08 PM, Magnus Holm <judofyr at gmail.com> wrote: >>>>> This "bug" is actually Apache''s fault. The problem occurs when you use >>>>> mod_rewrite to hide that you''re using dispatch.cgi. When you use >>>>> "RewriteRule ^(.*)$ dispatch.cgi" the following happens: >>>>> >>>>> * SCRIPT_NAME is set to /dispatch.cgi (since that''s the actual script >>>>> which gets ran) >>>>> * REDIRECT_SCRIPT_NAME is set to whatever SCRIPT_NAME was before >>>>> * PATH_INFO is emptied >>>>> >>>>> I''ve also tested this on 1.5 and it has the same problem. However, if >>>>> you use server/fastcgi.rb (not Rack as I''ve been testing with) you can >>>>> set the ENV[''FORCE_ROOT''] to 1 and it will re-set SCRIPT_NAME and >>>>> PATH_INFO using REQUEST_URI, which will (partly) solve the problem. >>>>> >>>>> Right now, we have no FORCE_ROOT in Rack, but here''s a simple fix: >>>>> >>>>> * Change .htaccess to "RewriteRule ^(.*)$ dispatch.cgi/$1" (You might >>>>> need to drop to slash). >>>>> * Add a middleware which sets SCRIPT_NAME to REDIRECT_SCRIPT_NAME >>>>> (http://pastie.org/235062) >>>>> >>>>> This isn''t really our problem, but rather Apache (which should be able >>>>> to alias CGI-scripts with the correct headers). It probably won''t >>>>> happen, so I guess we have to add some nasty hacks into Rack. >>>>> >>>>> I haven''t tried this on any other servers (LightTPD/Nginx), but as >>>>> long as there is no URL-rewriting (I know LightTPD can do it with >>>>> FastCGI) it''s probably no problem (maybe not even with, if it''s smart >>>>> enough). >>>>> >>>>> Here is a simple app which shows @env (and works on both 1.5 and 2.0): >>>>> http://pastie.org/235078. It would be great if you could test it on >>>>> different setups and see which requires special treatment. Check out >>>>> the Rack-spec for how the variables should be set: >>>>> http://rack.rubyforge.org/doc/files/SPEC.html >>>>> >>>>> On Wed, Jul 16, 2008 at 5:07 PM, Eric Mill <kprojection at gmail.com> wrote: >>>>>> >>>>>> Bluebie -- I tried doing this with FastCGI with the same settings >>>>>> (changed .htaccess to point to dispatch.fcgi, changed dispatch file to >>>>>> use Rack::Handler::FastCGI.run, got the exact same results. FastCGI >>>>>> will also suffer from these bugs. >>>>>> >>>>>> -- Eric >>>>>> >>>>>> On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna >>>>>> <blueberry at creativepony.com> wrote: >>>>>> > We are talking about cgi here, not fast cgi. Specifically CGI''s interactions >>>>>> > with mod_rewrite in apache. >>>>>> > _______________________________________________ >>>>>> > Camping-list mailing list >>>>>> > Camping-list at rubyforge.org >>>>>> > http://rubyforge.org/mailman/listinfo/camping-list >>>>>> > >>>>>> _______________________________________________ >>>>>> Camping-list mailing list >>>>>> Camping-list at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>> >>>>> >>>>> >>>>> -- >>>>> Magnus Holm >>>>> _______________________________________________ >>>>> Camping-list mailing list >>>>> Camping-list at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>> >>>> _______________________________________________ >>>> Camping-list mailing list >>>> Camping-list at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/camping-list >>>> >>> >>> >>> >>> -- >>> Magnus Holm >>> _______________________________________________ >>> Camping-list mailing list >>> Camping-list at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/camping-list >>> >> >
The 500-handling I''m used to appears to be gone. What''s the best approach here? -- Eric On Wed, Jul 16, 2008 at 6:08 PM, Eric Mill <kprojection at gmail.com> wrote:> I think I''ve got it working, with this as the ''fixer'' call: > > def call(env) > env[''SCRIPT_NAME''] = ''/'' > env[''PATH_INFO''] = env[''REDIRECT_URL''] > @app.call(env) > end > > I think you might have meant REDIRECT_URL and not REDIRECT_SCRIPT_NAME? > > Thank you Magnus! > > -- Eric > > On Wed, Jul 16, 2008 at 5:51 PM, Eric Mill <kprojection at gmail.com> wrote: >> Also worth noting is that PATH_INFO isn''t emptied - it''s set to "/" or >> "/login", the correct request path. >> >> -- Eric >> >> On Wed, Jul 16, 2008 at 5:40 PM, Eric Mill <kprojection at gmail.com> wrote: >>> Unfortunately this isn''t working. I''m checking my ENV and >>> REDIRECT_SCRIPT_NAME isn''t set to anything. I''m using the Rack spec >>> to try to figure out an alternative. >>> >>> Right now, requests to "/" go to a Camping error page which says >>> "/index.html not found!" and requests to "/login" (which should go to >>> a different controller) says "/login.html not found!". PATH_INFO has >>> been set to "/login.html" in this case. >>> >>> I also tried setting SCRIPT_NAME to be whatever REQUEST_URI is, but >>> this has the same effect as using the REDIRECT_SCRIPT_NAME approach. >>> >>> Continuing to investigate, >>> Eric >>> >>> On Wed, Jul 16, 2008 at 5:31 PM, Magnus Holm <judofyr at gmail.com> wrote: >>>> Simply replace Testing with TestingFixed in dispatch.cgi:11 and >>>> dispatch.fcgi:13 to see the diffenrence :-) >>>> >>>> On Wed, Jul 16, 2008 at 11:28 PM, Eric Mill <kprojection at gmail.com> wrote: >>>>> Magnus, this is terrific information, thank you for looking into this. >>>>> >>>>> I''m trying to follow your example - you use ApacheFixer to make a >>>>> "TestingFixed" class, but never use that class anywhere else. Do you >>>>> mean for the lines in dispatch.* to use "TestingFixed" instead of >>>>> "Testing"? >>>>> >>>>> I''m trying to use this to resolve my problems as we speak, >>>>> Eric >>>>> >>>>> On Wed, Jul 16, 2008 at 5:08 PM, Magnus Holm <judofyr at gmail.com> wrote: >>>>>> This "bug" is actually Apache''s fault. The problem occurs when you use >>>>>> mod_rewrite to hide that you''re using dispatch.cgi. When you use >>>>>> "RewriteRule ^(.*)$ dispatch.cgi" the following happens: >>>>>> >>>>>> * SCRIPT_NAME is set to /dispatch.cgi (since that''s the actual script >>>>>> which gets ran) >>>>>> * REDIRECT_SCRIPT_NAME is set to whatever SCRIPT_NAME was before >>>>>> * PATH_INFO is emptied >>>>>> >>>>>> I''ve also tested this on 1.5 and it has the same problem. However, if >>>>>> you use server/fastcgi.rb (not Rack as I''ve been testing with) you can >>>>>> set the ENV[''FORCE_ROOT''] to 1 and it will re-set SCRIPT_NAME and >>>>>> PATH_INFO using REQUEST_URI, which will (partly) solve the problem. >>>>>> >>>>>> Right now, we have no FORCE_ROOT in Rack, but here''s a simple fix: >>>>>> >>>>>> * Change .htaccess to "RewriteRule ^(.*)$ dispatch.cgi/$1" (You might >>>>>> need to drop to slash). >>>>>> * Add a middleware which sets SCRIPT_NAME to REDIRECT_SCRIPT_NAME >>>>>> (http://pastie.org/235062) >>>>>> >>>>>> This isn''t really our problem, but rather Apache (which should be able >>>>>> to alias CGI-scripts with the correct headers). It probably won''t >>>>>> happen, so I guess we have to add some nasty hacks into Rack. >>>>>> >>>>>> I haven''t tried this on any other servers (LightTPD/Nginx), but as >>>>>> long as there is no URL-rewriting (I know LightTPD can do it with >>>>>> FastCGI) it''s probably no problem (maybe not even with, if it''s smart >>>>>> enough). >>>>>> >>>>>> Here is a simple app which shows @env (and works on both 1.5 and 2.0): >>>>>> http://pastie.org/235078. It would be great if you could test it on >>>>>> different setups and see which requires special treatment. Check out >>>>>> the Rack-spec for how the variables should be set: >>>>>> http://rack.rubyforge.org/doc/files/SPEC.html >>>>>> >>>>>> On Wed, Jul 16, 2008 at 5:07 PM, Eric Mill <kprojection at gmail.com> wrote: >>>>>>> >>>>>>> Bluebie -- I tried doing this with FastCGI with the same settings >>>>>>> (changed .htaccess to point to dispatch.fcgi, changed dispatch file to >>>>>>> use Rack::Handler::FastCGI.run, got the exact same results. FastCGI >>>>>>> will also suffer from these bugs. >>>>>>> >>>>>>> -- Eric >>>>>>> >>>>>>> On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna >>>>>>> <blueberry at creativepony.com> wrote: >>>>>>> > We are talking about cgi here, not fast cgi. Specifically CGI''s interactions >>>>>>> > with mod_rewrite in apache. >>>>>>> > _______________________________________________ >>>>>>> > Camping-list mailing list >>>>>>> > Camping-list at rubyforge.org >>>>>>> > http://rubyforge.org/mailman/listinfo/camping-list >>>>>>> > >>>>>>> _______________________________________________ >>>>>>> Camping-list mailing list >>>>>>> Camping-list at rubyforge.org >>>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Magnus Holm >>>>>> _______________________________________________ >>>>>> Camping-list mailing list >>>>>> Camping-list at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>>> >>>>> _______________________________________________ >>>>> Camping-list mailing list >>>>> Camping-list at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>> >>>> >>>> >>>> >>>> -- >>>> Magnus Holm >>>> _______________________________________________ >>>> Camping-list mailing list >>>> Camping-list at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/camping-list >>>> >>> >> >
OK, I am good to go, working CGI and FastCGI .htaccess and dispatch.* files written. I changed REDIRECT_URI to REQUEST_URI. For CGI: * dispatch.cgi: http://pastie.org/235313 * .htaccess for CGI: http://pastie.org/235315 For FastCGI, based on the above: * in dispatch.cgi, change Rack::Handler::CGI.run to be Rack::Handler::FastCGI.run * in .htaccess change dispatch.cgi to be dispatch.fcgi Awesome. Thanks for everyone''s help. Especially Magnus and Jenna, you two rule. This seems like a good candidate for the github Camping wiki -- do people even know that thing exists, is it worth it? Or should I just add it to the Camping wiki on why''s site? -- Eric On Wed, Jul 16, 2008 at 6:13 PM, Eric Mill <kprojection at gmail.com> wrote:> The 500-handling I''m used to appears to be gone. What''s the best approach here? > > -- Eric > > On Wed, Jul 16, 2008 at 6:08 PM, Eric Mill <kprojection at gmail.com> wrote: >> I think I''ve got it working, with this as the ''fixer'' call: >> >> def call(env) >> env[''SCRIPT_NAME''] = ''/'' >> env[''PATH_INFO''] = env[''REDIRECT_URL''] >> @app.call(env) >> end >> >> I think you might have meant REDIRECT_URL and not REDIRECT_SCRIPT_NAME? >> >> Thank you Magnus! >> >> -- Eric >> >> On Wed, Jul 16, 2008 at 5:51 PM, Eric Mill <kprojection at gmail.com> wrote: >>> Also worth noting is that PATH_INFO isn''t emptied - it''s set to "/" or >>> "/login", the correct request path. >>> >>> -- Eric >>> >>> On Wed, Jul 16, 2008 at 5:40 PM, Eric Mill <kprojection at gmail.com> wrote: >>>> Unfortunately this isn''t working. I''m checking my ENV and >>>> REDIRECT_SCRIPT_NAME isn''t set to anything. I''m using the Rack spec >>>> to try to figure out an alternative. >>>> >>>> Right now, requests to "/" go to a Camping error page which says >>>> "/index.html not found!" and requests to "/login" (which should go to >>>> a different controller) says "/login.html not found!". PATH_INFO has >>>> been set to "/login.html" in this case. >>>> >>>> I also tried setting SCRIPT_NAME to be whatever REQUEST_URI is, but >>>> this has the same effect as using the REDIRECT_SCRIPT_NAME approach. >>>> >>>> Continuing to investigate, >>>> Eric >>>> >>>> On Wed, Jul 16, 2008 at 5:31 PM, Magnus Holm <judofyr at gmail.com> wrote: >>>>> Simply replace Testing with TestingFixed in dispatch.cgi:11 and >>>>> dispatch.fcgi:13 to see the diffenrence :-) >>>>> >>>>> On Wed, Jul 16, 2008 at 11:28 PM, Eric Mill <kprojection at gmail.com> wrote: >>>>>> Magnus, this is terrific information, thank you for looking into this. >>>>>> >>>>>> I''m trying to follow your example - you use ApacheFixer to make a >>>>>> "TestingFixed" class, but never use that class anywhere else. Do you >>>>>> mean for the lines in dispatch.* to use "TestingFixed" instead of >>>>>> "Testing"? >>>>>> >>>>>> I''m trying to use this to resolve my problems as we speak, >>>>>> Eric >>>>>> >>>>>> On Wed, Jul 16, 2008 at 5:08 PM, Magnus Holm <judofyr at gmail.com> wrote: >>>>>>> This "bug" is actually Apache''s fault. The problem occurs when you use >>>>>>> mod_rewrite to hide that you''re using dispatch.cgi. When you use >>>>>>> "RewriteRule ^(.*)$ dispatch.cgi" the following happens: >>>>>>> >>>>>>> * SCRIPT_NAME is set to /dispatch.cgi (since that''s the actual script >>>>>>> which gets ran) >>>>>>> * REDIRECT_SCRIPT_NAME is set to whatever SCRIPT_NAME was before >>>>>>> * PATH_INFO is emptied >>>>>>> >>>>>>> I''ve also tested this on 1.5 and it has the same problem. However, if >>>>>>> you use server/fastcgi.rb (not Rack as I''ve been testing with) you can >>>>>>> set the ENV[''FORCE_ROOT''] to 1 and it will re-set SCRIPT_NAME and >>>>>>> PATH_INFO using REQUEST_URI, which will (partly) solve the problem. >>>>>>> >>>>>>> Right now, we have no FORCE_ROOT in Rack, but here''s a simple fix: >>>>>>> >>>>>>> * Change .htaccess to "RewriteRule ^(.*)$ dispatch.cgi/$1" (You might >>>>>>> need to drop to slash). >>>>>>> * Add a middleware which sets SCRIPT_NAME to REDIRECT_SCRIPT_NAME >>>>>>> (http://pastie.org/235062) >>>>>>> >>>>>>> This isn''t really our problem, but rather Apache (which should be able >>>>>>> to alias CGI-scripts with the correct headers). It probably won''t >>>>>>> happen, so I guess we have to add some nasty hacks into Rack. >>>>>>> >>>>>>> I haven''t tried this on any other servers (LightTPD/Nginx), but as >>>>>>> long as there is no URL-rewriting (I know LightTPD can do it with >>>>>>> FastCGI) it''s probably no problem (maybe not even with, if it''s smart >>>>>>> enough). >>>>>>> >>>>>>> Here is a simple app which shows @env (and works on both 1.5 and 2.0): >>>>>>> http://pastie.org/235078. It would be great if you could test it on >>>>>>> different setups and see which requires special treatment. Check out >>>>>>> the Rack-spec for how the variables should be set: >>>>>>> http://rack.rubyforge.org/doc/files/SPEC.html >>>>>>> >>>>>>> On Wed, Jul 16, 2008 at 5:07 PM, Eric Mill <kprojection at gmail.com> wrote: >>>>>>>> >>>>>>>> Bluebie -- I tried doing this with FastCGI with the same settings >>>>>>>> (changed .htaccess to point to dispatch.fcgi, changed dispatch file to >>>>>>>> use Rack::Handler::FastCGI.run, got the exact same results. FastCGI >>>>>>>> will also suffer from these bugs. >>>>>>>> >>>>>>>> -- Eric >>>>>>>> >>>>>>>> On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna >>>>>>>> <blueberry at creativepony.com> wrote: >>>>>>>> > We are talking about cgi here, not fast cgi. Specifically CGI''s interactions >>>>>>>> > with mod_rewrite in apache. >>>>>>>> > _______________________________________________ >>>>>>>> > Camping-list mailing list >>>>>>>> > Camping-list at rubyforge.org >>>>>>>> > http://rubyforge.org/mailman/listinfo/camping-list >>>>>>>> > >>>>>>>> _______________________________________________ >>>>>>>> Camping-list mailing list >>>>>>>> Camping-list at rubyforge.org >>>>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Magnus Holm >>>>>>> _______________________________________________ >>>>>>> Camping-list mailing list >>>>>>> Camping-list at rubyforge.org >>>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>>>> >>>>>> _______________________________________________ >>>>>> Camping-list mailing list >>>>>> Camping-list at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Magnus Holm >>>>> _______________________________________________ >>>>> Camping-list mailing list >>>>> Camping-list at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>> >>>> >>> >> >
Just add it :)
1. It doesn''t work well when you try to mount it on a sub-directory 2. SCRIPT_NAME should be empty when it''s mounted on root (even though Camping can handle it). 3. REQUEST_URI contains query string too. What about env[''REQUEST_URI''].gsub(/\?.*/,'''')? It''s not really a portable solution, so I don''t think we should publish this all over the internet, but it''s good to hear that it''s working for you :-) -- It seems that (almost) everything I said earlier was wrong: Now PATH_INFO is suddenly / (I could have swear that it was gone!) And the reason I got REDIRECT_SCRIPT_NAME was because I had a "SetEnv SCRIPT_NAME /sub" in my .htaceess... It also looks like it''s impossible to auto magically detect what the proper SCRIPT_NAME should be. I guess the "hack" should be put into dispatch.cgi. What about this? http://pastie.org/236889 On Thu, Jul 17, 2008 at 2:08 AM, Eric Mill <kprojection at gmail.com> wrote:> OK, I am good to go, working CGI and FastCGI .htaccess and dispatch.* > files written. I changed REDIRECT_URI to REQUEST_URI. > > For CGI: > * dispatch.cgi: http://pastie.org/235313 > * .htaccess for CGI: http://pastie.org/235315 > > For FastCGI, based on the above: > * in dispatch.cgi, change Rack::Handler::CGI.run to be > Rack::Handler::FastCGI.run > * in .htaccess change dispatch.cgi to be dispatch.fcgi > > Awesome. Thanks for everyone''s help. Especially Magnus and Jenna, > you two rule. > > This seems like a good candidate for the github Camping wiki -- do > people even know that thing exists, is it worth it? Or should I just > add it to the Camping wiki on why''s site? > > -- Eric > > On Wed, Jul 16, 2008 at 6:13 PM, Eric Mill <kprojection at gmail.com> wrote: >> The 500-handling I''m used to appears to be gone. What''s the best approach here? >> >> -- Eric >> >> On Wed, Jul 16, 2008 at 6:08 PM, Eric Mill <kprojection at gmail.com> wrote: >>> I think I''ve got it working, with this as the ''fixer'' call: >>> >>> def call(env) >>> env[''SCRIPT_NAME''] = ''/'' >>> env[''PATH_INFO''] = env[''REDIRECT_URL''] >>> @app.call(env) >>> end >>> >>> I think you might have meant REDIRECT_URL and not REDIRECT_SCRIPT_NAME? >>> >>> Thank you Magnus! >>> >>> -- Eric >>> >>> On Wed, Jul 16, 2008 at 5:51 PM, Eric Mill <kprojection at gmail.com> wrote: >>>> Also worth noting is that PATH_INFO isn''t emptied - it''s set to "/" or >>>> "/login", the correct request path. >>>> >>>> -- Eric >>>> >>>> On Wed, Jul 16, 2008 at 5:40 PM, Eric Mill <kprojection at gmail.com> wrote: >>>>> Unfortunately this isn''t working. I''m checking my ENV and >>>>> REDIRECT_SCRIPT_NAME isn''t set to anything. I''m using the Rack spec >>>>> to try to figure out an alternative. >>>>> >>>>> Right now, requests to "/" go to a Camping error page which says >>>>> "/index.html not found!" and requests to "/login" (which should go to >>>>> a different controller) says "/login.html not found!". PATH_INFO has >>>>> been set to "/login.html" in this case. >>>>> >>>>> I also tried setting SCRIPT_NAME to be whatever REQUEST_URI is, but >>>>> this has the same effect as using the REDIRECT_SCRIPT_NAME approach. >>>>> >>>>> Continuing to investigate, >>>>> Eric >>>>> >>>>> On Wed, Jul 16, 2008 at 5:31 PM, Magnus Holm <judofyr at gmail.com> wrote: >>>>>> Simply replace Testing with TestingFixed in dispatch.cgi:11 and >>>>>> dispatch.fcgi:13 to see the diffenrence :-) >>>>>> >>>>>> On Wed, Jul 16, 2008 at 11:28 PM, Eric Mill <kprojection at gmail.com> wrote: >>>>>>> Magnus, this is terrific information, thank you for looking into this. >>>>>>> >>>>>>> I''m trying to follow your example - you use ApacheFixer to make a >>>>>>> "TestingFixed" class, but never use that class anywhere else. Do you >>>>>>> mean for the lines in dispatch.* to use "TestingFixed" instead of >>>>>>> "Testing"? >>>>>>> >>>>>>> I''m trying to use this to resolve my problems as we speak, >>>>>>> Eric >>>>>>> >>>>>>> On Wed, Jul 16, 2008 at 5:08 PM, Magnus Holm <judofyr at gmail.com> wrote: >>>>>>>> This "bug" is actually Apache''s fault. The problem occurs when you use >>>>>>>> mod_rewrite to hide that you''re using dispatch.cgi. When you use >>>>>>>> "RewriteRule ^(.*)$ dispatch.cgi" the following happens: >>>>>>>> >>>>>>>> * SCRIPT_NAME is set to /dispatch.cgi (since that''s the actual script >>>>>>>> which gets ran) >>>>>>>> * REDIRECT_SCRIPT_NAME is set to whatever SCRIPT_NAME was before >>>>>>>> * PATH_INFO is emptied >>>>>>>> >>>>>>>> I''ve also tested this on 1.5 and it has the same problem. However, if >>>>>>>> you use server/fastcgi.rb (not Rack as I''ve been testing with) you can >>>>>>>> set the ENV[''FORCE_ROOT''] to 1 and it will re-set SCRIPT_NAME and >>>>>>>> PATH_INFO using REQUEST_URI, which will (partly) solve the problem. >>>>>>>> >>>>>>>> Right now, we have no FORCE_ROOT in Rack, but here''s a simple fix: >>>>>>>> >>>>>>>> * Change .htaccess to "RewriteRule ^(.*)$ dispatch.cgi/$1" (You might >>>>>>>> need to drop to slash). >>>>>>>> * Add a middleware which sets SCRIPT_NAME to REDIRECT_SCRIPT_NAME >>>>>>>> (http://pastie.org/235062) >>>>>>>> >>>>>>>> This isn''t really our problem, but rather Apache (which should be able >>>>>>>> to alias CGI-scripts with the correct headers). It probably won''t >>>>>>>> happen, so I guess we have to add some nasty hacks into Rack. >>>>>>>> >>>>>>>> I haven''t tried this on any other servers (LightTPD/Nginx), but as >>>>>>>> long as there is no URL-rewriting (I know LightTPD can do it with >>>>>>>> FastCGI) it''s probably no problem (maybe not even with, if it''s smart >>>>>>>> enough). >>>>>>>> >>>>>>>> Here is a simple app which shows @env (and works on both 1.5 and 2.0): >>>>>>>> http://pastie.org/235078. It would be great if you could test it on >>>>>>>> different setups and see which requires special treatment. Check out >>>>>>>> the Rack-spec for how the variables should be set: >>>>>>>> http://rack.rubyforge.org/doc/files/SPEC.html >>>>>>>> >>>>>>>> On Wed, Jul 16, 2008 at 5:07 PM, Eric Mill <kprojection at gmail.com> wrote: >>>>>>>>> >>>>>>>>> Bluebie -- I tried doing this with FastCGI with the same settings >>>>>>>>> (changed .htaccess to point to dispatch.fcgi, changed dispatch file to >>>>>>>>> use Rack::Handler::FastCGI.run, got the exact same results. FastCGI >>>>>>>>> will also suffer from these bugs. >>>>>>>>> >>>>>>>>> -- Eric >>>>>>>>> >>>>>>>>> On Mon, Jul 14, 2008 at 7:40 PM, Bluebie, Jenna >>>>>>>>> <blueberry at creativepony.com> wrote: >>>>>>>>> > We are talking about cgi here, not fast cgi. Specifically CGI''s interactions >>>>>>>>> > with mod_rewrite in apache. >>>>>>>>> > _______________________________________________ >>>>>>>>> > Camping-list mailing list >>>>>>>>> > Camping-list at rubyforge.org >>>>>>>>> > http://rubyforge.org/mailman/listinfo/camping-list >>>>>>>>> > >>>>>>>>> _______________________________________________ >>>>>>>>> Camping-list mailing list >>>>>>>>> Camping-list at rubyforge.org >>>>>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Magnus Holm >>>>>>>> _______________________________________________ >>>>>>>> Camping-list mailing list >>>>>>>> Camping-list at rubyforge.org >>>>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>>>>> >>>>>>> _______________________________________________ >>>>>>> Camping-list mailing list >>>>>>> Camping-list at rubyforge.org >>>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Magnus Holm >>>>>> _______________________________________________ >>>>>> Camping-list mailing list >>>>>> Camping-list at rubyforge.org >>>>>> http://rubyforge.org/mailman/listinfo/camping-list >>>>>> >>>>> >>>> >>> >> > _______________________________________________ > Camping-list mailing list > Camping-list at rubyforge.org > http://rubyforge.org/mailman/listinfo/camping-list >-- Magnus Holm