LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-24-2010, 02:19 PM   #1
samarudge
Member
 
Registered: Nov 2010
Posts: 33

Rep: Reputation: 0
Apache2.2 MOD_PROXY ProxPass with HTTP Authentication


I have a server acting as a proxy to a couple of IP cameras on my local network. The IP cameras require HTTP-Authentication (Basic) but I want the outward facing Apache server to automatically log in without prompting the user for a login. My current configuration is

Code:
ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://username:password@ipcamera.lan/
    ProxyPassReverse / http://username:password@ipcamera.lan/
That works as a proxy but still asks for a HTTP Auth login. Can I get Apache to pass the login details to the IP cameras so users can just hit up the proxy and view the camera without having to log in?
-Sam
 
Old 12-24-2010, 06:24 PM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,072

Rep: Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969
Hi,

You need to set usernameassword as a base 64 encoded string in the request header.
Run:
Code:
echo username:password | mmencode
to get the base 64 usernameassword.
Then use RequestHeader to set the authorization in the header according to the previous command output:
Code:
ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    RequestHeader set Authorization "Basic <base64 username:password>"
    ProxyPass / http://ipcamera.lan/
    ProxyPassReverse / http://ipcamera.lan/
Note that you need to add/enable the mod_headers module in order for the above to work.

Regards
 
1 members found this post helpful.
Old 12-25-2010, 05:07 AM   #3
samarudge
Member
 
Registered: Nov 2010
Posts: 33

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by bathory View Post
Hi,

You need to set usernameassword as a base 64 encoded string in the request header.
Run:
Code:
echo username:password | mmencode
to get the base 64 usernameassword.
Then use RequestHeader to set the authorization in the header according to the previous command output:
Code:
ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    RequestHeader set Authorization "Basic <base64 username:password>"
    ProxyPass / http://ipcamera.lan/
    ProxyPassReverse / http://ipcamera.lan/
Note that you need to add/enable the mod_headers module in order for the above to work.

Regards
Awesome thanks!

As a note I didn't have mmencode on my system so I used base64 instead
 
Old 06-27-2012, 06:51 AM   #4
jnsunkersett
LQ Newbie
 
Registered: Aug 2011
Posts: 2

Rep: Reputation: Disabled
Hi,

I found this post, relevant to a google search; so this post ... please pardon me if I am revining a very very old thread.

Can someone please elaborate; link me to;
1. What is mmencode?
2. How is the authorization set in the RequestHeader

thank you
Jeevan
 
Old 06-27-2012, 08:53 AM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,072

Rep: Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969Reputation: 1969
Hi,

1. mmencode is used to encode/decode a string to/from base64 format. The same can be done using the base64 command as OP did, mimencode etc.
2. Using mod_headers, you set the header RequestHeader to contain the Authorization "Basic" and the username/password pair encoded in base64. This is the format used by apache's mod_auth to access protected pages. You can take a look here for more details on http headers.

Regards
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
apache2 mod_proxy failing with ssl eco Linux - Server 1 05-21-2010 01:58 AM
[SOLVED] 4 websites on different IP how to host them using apache2 mod_proxy newbie question. tkmsr Linux - Server 3 04-13-2010 12:46 PM
mod_proxy under Apache2 not working with some https sites pmvp5 Linux - Server 0 10-10-2008 04:54 AM
Apache2 and mod_proxy Maniac0Maniac Linux - Software 3 04-17-2006 06:51 PM
apache2 mod_proxy - swiki bkeating Linux - Software 0 10-28-2003 04:58 PM

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

All times are GMT -5. The time now is 05:03 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