LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 07-21-2009, 08:38 AM   #1
curtisa
Member
 
Registered: Oct 2005
Location: Switzerland
Distribution: Ubuntu
Posts: 33

Rep: Reputation: 16
Correct Apache RewriteCond to stop proxying ...


I am using Apache to reverse proxy through to my application server via mod_rewrite but I want to prevent my server from being used to proxy to other addresses.

I thought I'd try to use a few RewriteCond followed by a RewriteRule to check if the address being requested is my domain, and if not return a 403. Can someone tell me if what I have below is correct pls (cos I'm not sure it's working)..

Code:
RewriteCond %{REQUEST_URI} "!http://www.mydomain.com/.*$" [NC]
RewriteRule .* - [F]
So what I'm trying to say is simply if the URI isn't my domain then return a 403 ([F]).

Is this right ?

Tks vm
 
Old 07-21-2009, 11:38 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,215
Blog Entries: 1

Rep: Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067Reputation: 2067
You need to use HTTP_HOST to specify your server and not REQUEST_URI:
Code:
RewriteCond %{HTTP_HOST}   !^www.mydomain.com [NC]
RewriteRule ^(.*) - [F]
 
  


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
apache httpd config:how can i rewrite urls in javascript while reverse proxying amolgupta Linux - Software 0 07-20-2009 02:43 AM
Apache(everything works ????????????Correct config bunty82 Linux - Server 1 07-24-2008 04:20 PM
RewriteCond & Rewrite Rule Problemo sea-bass Linux - Server 0 04-07-2008 11:44 AM
giving apache the correct permissions dflorence Linux - Newbie 3 11-06-2003 09:27 AM
Apache server: pointing to the correct file WiWa Linux - Software 4 08-11-2003 08:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 02:18 AM.

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