Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need a rewrite rule to pass http://username:password@mysite:7000/

Posted on 2003-11-13
4
Medium Priority
?
8,665 Views
Last Modified: 2008-02-01
Hello,

I am trying to create a rewrite rule that proxies a user to a site that requires basic auth, and provides the username & password which logs them in.

Here is the rule I attempted:
RewriteRule ^/invoke(.*) http://username:password@mysite:7000/invoke$1 [NC,P]
ProxyPassReverse /invoke/ http://username:password@mysite:7000/invoke/

The rule does successfully pass you on to the proper site, but the user is still prompted for the username and password. If you provide the user and password you do get the page successfully, but I don't want the user to be prompted.

If I post the username and passworld at mysite directly:
http://username:password@mysite:7000/invoke/index.htm

I am logged in appropriately without being prompted, but for some reason I cannot get this to work with a rewriterule!

Help!

Thanks,
Liam
0
Comment
Question by:Liam2e
2 Comments
 
LVL 16

Accepted Solution

by:
_nn_ earned 1000 total points
ID: 9747563
A browser will possibly translate the http://username:password@mysite:7000/invoke/index.htm syntax into a http://mysite:7000/invoke/index.htm request combined with additional auth headers, but I strongly doubt that Apache's mod_rewrite (or any other module for that matter) can do that.

I would approach the problem with another angle. You could for instance get the mysite host to accept connections coming from the IP address of the reverse proxy you're currently setting up. If that mysite host is also running Apache, it's just a matter of using the Satisfy directive, something like

Require valid-user
Allow from <IP of proxy>
Satisfy Any

(see http://httpd.apache.org/docs-2.0/mod/core.html#satisfy for details)

Else, you could of course use some script (CGI, PHP, etc) to do the job, but I suspect you don't like that idea.
0
 
LVL 27

Assisted Solution

by:BigRat
BigRat earned 1000 total points
ID: 9927801
mod_proxy does not pass forward basic authentication which is why the user gets prompted. I would suggest you rewrite the incoming url into a perl script which instantiates an http object, passes the authentication and then the url.

Long term this is better, since mod_proxy does not handle cookies. The proxy_pass_reverse applies only to the Location: http response header.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses
Course of the Month6 days, 8 hours left to enroll

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question