LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-26-2010, 09:19 AM   #1
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Rep: Reputation: 31
Question more fun with Apache rewrites proxies and trailing slashes


I have a back-end server behind a proxy machine. I would like non-SSL requests to the proxy to be rewritten into HTTPS requests to the back-end server, while not screwing up URLs with missing or misplaced trailing URL slashes. So far, on the proxy side, I have this in a virtual host for port 80:

Code:
  ReWriteEngine On 
  # trailing slash fix:
  RewriteCond %{SERVER_NAME} my.proxy.com$ [NC]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^(.*?[^/])$ $1/ [R]
  # send all requests to the HTTPS site:
  RewriteCond %{SERVER_NAME} my.proxy.com$ [NC]
  RewriteRule ^/(.*)$ https://my.proxy.com/$1 [R=301,NC,L]
I included the SERVER_NAME conditions because there are other HTTPS virtual hosts being served by this proxy, and it seemed that without these conditions this virtual host was "stealing" requests for other hosts and screwing them up.

And this within a virtual host in ssl.conf on the proxy:

Code:
  SSLProxyEngine on
  ProxyPass / https://backend.server.com:443/
  ProxyPassReverse / https://backend.server.com:443/
I found the proxy requests would fail without the 'SSLProxyEngine on' directive in ssl.conf, as well as without adding 'NameVirtualHost *:443' to ssl.conf.

The results so far are that a base URL request rewrite works:
http://my.proxy.com ==> https://my.proxy.com/
https://my.proxy.com ==> https://my.proxy.com/

But adding anything else to the URL fails, as the back-end server name gets stuck into the proxied URL:
http://my.proxy.com/~something ==> https://backend.server.com/~something/

The rewrite log seems okay, I think. So I guess this is failing at the reverse proxy rule? Where am I going wrong?
 
Old 03-29-2010, 11:05 AM   #2
deesto
Member
 
Registered: May 2002
Location: NY, USA
Distribution: FreeBSD, Fedora, RHEL, Ubuntu; OS X, Win; have used Slackware, Mandrake, SuSE, Xandros
Posts: 448

Original Poster
Rep: Reputation: 31
In summary, this is what I would like to do:
- On the proxy, redirect all HTTP requests for this host to HTTPS
- On the proxy, redirect all HTTPS requests for this host to the back end server
- On the back-end, redirect all ~user requests to an NFS web directory (/nfs-path/~user/www)
- Enable the use of .htaccess files in the NFS web directories so users can protect content with passwords

It seems as if all of these are working, except anything but a root domain request that's missing a trailing slash gets screwed up ( proxy.com/~user gets rewritten into backend.com/~user, which does not exist).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache trailing slash problem for multiple rewrites deesto Linux - Server 6 01-16-2011 01:01 AM
Using MySQL to manage rewrites for Apache bahbahthelamb Linux - Server 2 03-08-2010 12:19 PM
Apache rewrites screwing up images deesto Linux - Server 7 01-22-2010 03:58 PM
Strange apache trailing / problem - Slack-current, apache 1.3.33 vamp Linux - Networking 1 01-30-2005 07:28 PM
Apache trailing slash boondock_saint Linux - General 9 07-07-2004 03:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 12:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration