Forum Moderators: phranque

Message Too Old, No Replies

modified proxy

super newb here... any suggestions welcomed

         

ihtfp004

1:54 pm on Jun 3, 2004 (gmt 0)

10+ Year Member



Hi everyone,

I'm a super newb when it comes to apache and I have come here for guidance. I have set up my apache server into a proxy and it is working fine. But, I need to modify the proxy so that anyone who connects to my proxy gets sent to a .html file on my computer. The reason for this is that I have 2 proxies and I want to take this one proxy down by putting up a page that tells the users to change their connection settings on their computer.

So, when people connect to my proxy; no matter what the user puts for a website it always goes to my specified file. i.e. user tries to go to www.google.com but gets sent to /user/stuff/MyPage.html

Would I have to use mod_rewrite for this or is there and easier way to do this? I don't even know where to start with this thing. Any suggestions are welcomed. Thanks in advance.

ihtfp004

7:40 pm on Jun 3, 2004 (gmt 0)

10+ Year Member



alright i read the other posts on webmasterworld.com for about 2 hours and googled for another 2. and this is what i get. doesn't work tho.

<IfModule mod_rewrite.c>

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_REFERER}!^$
RewriteRule (.*) file:/var/apache/htdos/index.html/$1 [R=301,L]

</IfModule>

I honestly don't know what I'm doing. i thought i knew what i was doing but i obviously don't. all i want is my proxy to automatically send the user to my file on the first connection. after that I think i can just trap them in an infinite loop.

please help. anyone please. S.O.S. MAYDAY MAYDAY!

jdMorgan

9:21 pm on Jun 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ihtfp004,

Welcome to WebmasterWorld [webmasterworld.com]!

I suspect that many here could not figure out what you needed...

You are attempting to specify an external redirect by using [R=301]. I'd suggest just using [L]. Also, specify only a local path as the substitution, i.e., leave off the "file:" part.

Jim

ihtfp004

9:50 pm on Jun 3, 2004 (gmt 0)

10+ Year Member



thanks. i'll try that. Yeah i know this is an odd situation; it seems like i'm forcing an error. I've been banging my head on the head on the desk trying to redirect all proxy requests to my specified file.

jdMorgan

10:31 pm on Jun 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Also, I assume that the definition of "proxy request" means any request which is not to your server itself, but rather to an outside domain. So you may want to use %{HTTP_HOST} to check to see if it's an "internal" domain request, and do the rewrite otherwise. I don't think %{HTTP_REFERER} is what you want.

So I'd suggest:


Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?yourcompany\.com [NC]
RewriteRule !\.(gif¦jpe?g¦png¦mp3¦wav¦au¦mpe?g¦wmv¦mov¦rmi¦avi¦asf¦swf)$ /htdocs/index.html [L]

The RewriteRule pattern is intended to avoid trying to rewrite/redirect media-type file requests to your html file, since that won't work anyway. The list is non-comprehesive, but should cover 95% of everything.

Change all broken pipe "¦" characters to solid pipe characters before use -- posting on the board here modifies them.

Jim

ihtfp004

1:17 pm on Jun 4, 2004 (gmt 0)

10+ Year Member



sorry for not being clearer. I'm pretty stupid

the proxy server is my proxy server that I maintain. People connect to my proxy to surf the web. What I want to do is redirect all traffic going through my proxy to my index.html which is located on the proxy server itself.

For example:

USER1 -> connects to my proxy 12.34.56.78 -> they type in www.google.com (to go to google.com) -> but instead gets redirected to my index.html

USER1 -> connects to my proxy 12.34.56.78 -> they type in www.cnn.com (to go to cnn.com) -> they get redirected to my index.html

So what I'm trying to do is, when users connect through my proxy server (to surf the web) the server would ignore their requests and automatically send them to the index.html (located on the proxy itself) no matter what they type in. In essence it's a trap. The users would not be able to use my proxy server to surf and would be forced to view my notice page until they changed their internet connection settings.

The actual mod_rewrite stuff I am trying to do is on the proxy server itself.

ihtfp004

3:03 pm on Jun 4, 2004 (gmt 0)

10+ Year Member



OK i thought i got it but it doesn't work quite the way i want it to. i'm trying to stay away from the mod_rewrite cuz i'm too stupid to understand how to use it.

i included the line: ProxyBlock *
in my mod_proxy.c directive to block all proxy requests and make it a HTTP error 403

then i added the line: ErrorDocument 403 /index.html
to have all server requests go to that document.

well it's giving me a HTTP 403 error but it's not going to the customized error page that I specified. any have any ideas why this isn't working?