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

Breaks Gallery2 installation (issues with mod_rewrite?) #63

Closed
GoogleCodeExporter opened this Issue Apr 6, 2015 · 9 comments

Comments

Projects
None yet
1 participant
@GoogleCodeExporter

GoogleCodeExporter commented Apr 6, 2015

What steps will reproduce the problem?
1. Install Gallery 2 with /gallery2 as base path (http://gallery.menalto.com/).
2. Set up Gallery 2's mod_redirect options (search engine friendly URLs for 
viewing images, ...)
3. Access Gallery 2 while mod_pagespeed is enabled.

What is the expected output? What do you see instead?

CSS and Javascript fails to load. CSS URLs point to stuff like ' 
/gallery2/cc.dd96a8e3391b4c1fed53b9f21dc98dac.modules,_core,_[...]' and give a 
'Forbidden' error when accessed, JS URLs point to 
'/gallery2/jm.323fc81c51191367c455f73008420775.main,ophp?g2_view=core,oCom[...]'
 which returns a page like this:
-----------------------
Apache server with mod_pagespeed

OK

NOT 
FOUNDhttp://hostname/gallery2/jm.323fc81c51191367c455f73008420775.main,ophp[...]
-----------------------

What version of the product are you using (please check X-Mod-Pagespeed
header)?

 0.9.0.0-128

On what operating system?

Debian Linux (testing)

Which version of Apache?

2.2.16-3

Which MPM?

Prefork

Additional info:

Gallery2's generated .htaccess with rewrite rules:


<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /gallery2/

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   -   [L]

    RewriteCond %{QUERY_STRING} view=core.DownloadItem
    RewriteCond %{HTTP:Referer} !^[a-zA-Z0-9\+\.\-]+://sitename.com/   [NC]
    RewriteCond %{HTTP:Referer} !^$
    RewriteRule .   /gallery2/main.php   [F,L]
    RewriteCond %{THE_REQUEST} /gallery2/v/slideshow/fullscreen/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=slideshowapplet.SlideshowApplet&g2_path=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/c/view/([0-9]+)\.html(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=comment.ShowAllComments&g2_itemId=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/v/slideshow/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=slideshow.Slideshow&g2_path=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/rss/([^\/\?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=rss.Render&g2_name=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/srss/([0-9]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=rss.SimpleRender&g2_itemId=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/tag/([^?/]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_view=tags.VirtualAlbum&g2_tagName=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/f/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_controller=permalinks.Redirect&g2_filename=%1   [QSA,L]
    RewriteCond %{THE_REQUEST} /gallery2/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_URI} !/gallery2/main\.php$
    RewriteRule .   /gallery2/main.php?g2_path=%1   [QSA,L]
</IfModule>

Original issue reported on code.google.com by lev.ar...@gmail.com on 9 Nov 2010 at 10:35

@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

Note that it is likely you will need to add rewrite rules in order to handle 
rewritten Instaweb resources, and/or take advantage of per-directory resource 
configurations.  We're not experienced with wholesale rewrites such as the ones 
you describe above; it might be worth asking on mod-pagespeed-discuss to see if 
there are others who have encountered similar problems and can explain how to 
address them.

Original comment by jmaes...@google.com on 2 Dec 2010 at 4:49

@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

I'll take this.  A few observations:

1. Lev -- this is a great bug write-up.  We can immediately see what the 
problem is.

2. The immediate problem is caused by mod_rewrite corrupting URLs that were 
rewritten by mod_pagespeed.  In version 0.9.11.* and later, the URL format 
generated by mod_pagespeed will be better, but I think this mod_rewrite 
configuration will still be broken.  It might be possible to hand-edit the 
regexps so they do the right thing with mod_pagespeed's rewritten URLs.

3. The real problem, I think, is that mod_rewrite runs after mod_pagespeed and 
a cleaner solution for this and other problems is to figure out how to get 
mod_rewrite to run first.

Original comment by jmara...@google.com on 22 Dec 2010 at 2:55

@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

We have fixed mod_pagespeed so that it will mark as handled all requests for 
its own resources upstream of mod_rewrite.  If you can update to the trunk, 
please let us know if this resolves the Gallery2 symptom.

http://code.google.com/p/modpagespeed/source/detail?r=325

Original comment by jmara...@google.com on 23 Dec 2010 at 4:28

  • Changed state: Fixed
@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

Original comment by sligocki@google.com on 23 Dec 2010 at 8:17

  • Added labels: release-note
@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

Took me a while to pull trunk (getting 502 GATEWAY errors) and compile the 
Debian packages off it. Just finished installing and at first sight, this seems 
to work. (At least my Gallery2, Wordpress and Typo3 installs seem OK, and those 
rely heavily on mod_rewrite.)

Original comment by lev.ar...@gmail.com on 23 Dec 2010 at 9:19

@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

I would like to add that this, or a similar issue, still affects gallery2 in 
the latest svn checkout.  I had to add a ModPagespeed off  line to .htaccess 
for gallery2, otherwise it would cause Apache connections to stay in a 
persistent Waiting for Reply connection state.


Here's a sample of the errors generated in error_log by mod_pagespeed:

[Sun May 29 23:06:34 2011] [warn] [mod_pagespeed 0.9.0.0-0 @12684] 
[0529/230634:WARNING:net/instaweb/apache/serf_url_async_fetcher.cc(909)] Fetch 
timed out: 
http://domain/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=122412&g2_se
rialNumber=1
[Sun May 29 23:06:34 2011] [warn] [mod_pagespeed 0.9.0.0-0 @12684] 
[0529/230634:WARNING:net/instaweb/apache/serf_url_async_fetcher.cc(909)] Fetch 
timed out: 
http://domain/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=122550&g2_se
rialNumber=1
[Sun May 29 23:06:34 2011] [warn] [mod_pagespeed 0.9.0.0-0 @12684] 
[0529/230634:WARNING:net/instaweb/apache/serf_url_async_fetcher.cc(909)] Fetch 
timed out: 
http://domain/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=122573&g2_se
rialNumber=1
[Sun May 29 23:06:34 2011] [warn] [mod_pagespeed 0.9.0.0-0 @12684] 
[0529/230634:WARNING:net/instaweb/apache/serf_url_async_fetcher.cc(909)] Fetch 
timed out: 
http://domain/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=122616&g2_se
rialNumber=1
[Sun May 29 23:06:34 2011] [warn] [mod_pagespeed 0.9.0.0-0 @12684] 
[0529/230634:WARNING:net/instaweb/apache/serf_url_async_fetcher.cc(909)] Fetch 
timed out: 
http://domain/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=122684&g2_se
rialNumber=1


mod_pagespeed was built earlier today, using the source fetched with gclient.

(http://modpagespeed.googlecode.com/svn/trunk/src/)

Original comment by laebsh...@gmail.com on 30 May 2011 at 4:41

@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

Hi Laebsh...

Can you indicate whether the URL(s) on which we are timing out, e.g.

   http://domain/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=122412&g2_serialNumber=1

are correct?  E.g. type the domain-corrected version of that into the URL bar 
of your browser and see if it looks like you expect.

If that URL is mangled it's possible that we still have an issue with 
mod_rewrite.

Another guess I have is that this is not related to mod_rewrite, but is some 
other issue related to fetching the resource.  One wild guess is that the 
resource-request requires a cookie, and that mod_pagespeed is not properly 
handling that.

Can you tell me -- this php request that's failing -- what's that for?  I can't 
tell from the URL whether this is to an HTML page or an image or javascript or 
CSS.  Could you correlate this with an HTML element in  your main site?

Is there any chance you could give us a real URL so we could see the problem 
from our end?

Thanks!

Original comment by jmara...@google.com on 30 May 2011 at 11:33

@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

[deleted comment]
@GoogleCodeExporter

This comment has been minimized.

GoogleCodeExporter commented Apr 6, 2015

Nevermind.  Looks like the primary issue was Gallery2 not killing MySQL 
connections properly, completely unrelated to mod_pagespeed.

Original comment by laebsh...@gmail.com on 31 May 2011 at 1:55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment