CAT | Administration
16
Proxy/ReverseProxy and Apache2
1 Comment · Posted by admin in Administration, Linux, apache
I recently configured Apache2 to be a ReverseProxy/Proxy and thought I would share my experiences while it was still fresh. Having never configured any kind of proxy, I foundĀ this webpage very informative. The scenario I would like to use for my example is that I have three internal web servers called
| Site | Local IP | Remote IP | Port |
|---|---|---|---|
| www.reallycoolsite.com | 192.168.1.102 | 10.15.22.1 | 80 |
| www.justcoolsite.com | 192.168.1.102 | 10.15.22.2 | 80 |
| www.reallylamesite.com | 192.168.1.44 | 10.15.22.3 | 80 |
Alright…pretty straight forward right? If you are in a situation that I was when I started, you haven’t done much more than install apache from source and added a few modules here and there occasionally. The way I solved the problem was to create name-based virtual host for each of the servers.
our example would look like
#you can listen on specific ports for requests if you like
#(ex->Listen 192.168.1.102:80)
#I use the below statement to listen on 80 for all requests
Listen *:80
#Because we have multiple names mapped to same ip
NameVirtualHost 192.168.1.102:80
<VirtualHost 192.168.1.102:80 >
ServerName www.reallycoolsite.com
ProxyRequests Off
ProxyPass / http://10.15.22.1/
ProxyReverse / http://www.reallycoolsite.com/
ProxyPreserveHost On
ErrorLog reallycoolsite_error_log
CustomLog reallycoolsite_access_logs
</VirtualHost >
<VirtualHost 192.168.1.102:80 >
ServerName www.justcoolsite.com
ProxyRequests Off
ProxyPass / http://10.15.22.2/
ProxyReverse / http://www.justcoolsite.com/
ProxyPreserveHost On
ErrorLog justcoolsite_error_log
CustomLog justcoolsite_access_logs
</VirtualHost >
<VirtualHost 192.168.1.44:80 >
ServerName www.reallylamesite.com
ProxyRequests Off
ProxyPass / http://10.15.22.3/
ProxyReverse / http://www.reallylamesite.com/
ProxyPreserveHost On
ErrorLog reallylamesite_error_log
CustomLog reallylamesite_access_logs
</VirtualHost >
If you receive errors during the communication of your proxy and your server, it may be a good idea to investigate if you have an http protocol error discussed at the bottom of this page
The following two lines are pulled from the reference and fixed a problem I had with one of my IIS servers using SSL(for more info about the issue, go here
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
My apache configuration file(httpd.conf) was the file I used to edit my settings.. Your file may be different depending on how new your apache version is. I found that some implementations called the configuration file apache.conf…. I hope this blog entry is helpful you, Happy Configuring!
apache · configuration · Linux
Inquiring minds want to know, what is this su - and why is it different than su? Well, if you are like me, you didn’t even know that su - existed. I ran into this problem when I was trying to add a new user to a new Linux machine. Remote root login was disabled(for obvious reasons:D) and I was logged in with my regular non-privileged user account. Well, normally the story goes like this…
- su
- Authenticate
- useradd account
- set password
- log out of privileged account
- Take coffee break from all the hard work and call it a day
No so today:( . When I attempted to run step three(useradd), I received a command not found error. “That’s weird” I thought. How could a machine not have this basic command. I looked in the bin directory to see if it was some kind of path error I was having. Thinking that this was the case, I was shocked to see that none of the user commands(adduser, usermod, deluser) where there.
After a few minutes of scratching my head, I asked someone more versed in Linux than I what they thought. After walking through each of the steps I had taken, my mistake was easily spotted. I hadn’t added the ‘-’ to the su command. Thinking that the explanation was weird, I checked with google for the su - command. Sure enough, the link to Wikipedia had this to say about it,
Optionally, you can use a hyphen with su to invoke a login shell and assume the target user’s complete user environment:
I am glad I had someone to point this out to me… It could have been a longer and very frustrating ordeal. It was also a lesson for me to refer more to the man pages(it had the answer there too). I hope this blog entry helps someone else who is confronted with this situation.
