Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi group,
I am attempting to configure my Apache web server to redirect any traffic for one IP to another IP. I have three IP addresses 10.1.1.12, 10.1.1.13 and 10.1.1.56. 12 and 13 are running on the same Raspberry Pi, running Raspbian. I'm using the Rewrite option of Apache with the following configuration:
You have an error in the RewriteRule. Replace %(REQUEST_URI) with %{REQUEST_URI}
Quote:
When I attempt 'wget 10.1.1.13', I get the index.html for 10.1.1.12 and nothing in the rewrite.log.
Rewrite should work. Since you're getting 10.1.1.12 instead of 10.1.1.56 or the initial 10.1.1.13, it could be a browser cache problem, so clear your browser cache before testing, or start a new session.
Re. logging it should work also,
I guess you're running apache-2.2.x, because RewriteLog is dropped in the new apache-2.4.x. So make sure that you restart apache after editing the config file(s)
A couple of things:
You load twice mod_rewrite (and info_module if it matters).
You have an error in the RewriteRule. Replace %(REQUEST_URI) with %{REQUEST_URI}
Rewrite should work. Since you're getting 10.1.1.12 instead of 10.1.1.56 or the initial 10.1.1.13, it could be a browser cache problem, so clear your browser cache before testing, or start a new session.
Re. logging it should work also,
I guess you're running apache-2.2.x, because RewriteLog is dropped in the new apache-2.4.x. So make sure that you restart apache after editing the config file(s)
Regards
Thanks for the reply.
Your right about the loaded modules, don't think that is a problem, but commented out my loading.
Not a caching problem ( I believe ), using wget.
Changed '(' to '}', no effect..
Used "service apache2 restart" after making changes.
Code:
root:~; service apache2 restart
[....] Restarting web server: apache2[Tue Apr 26 20:30:06 2016] [warn] module info_module is already loaded, skipping
... waiting .[Tue Apr 26 20:30:09 2016] [warn] module info_module is already loaded, skipping
. ok
I changed the host server to my laptop and got it to work with this file:
RewriteEngine On
LogLevel info rewrite:trace1
RewriteCond %{SERVER_ADDR} ^(10.1.1.57)
RewriteRule ^.* http://10.1.1.13/%{REQUEST_URI} [R=301,L]
In the above rule, you use 10.1.1.57 and not 10.1.1.56 as in your OP, so verify the IP you want to redirect
Other than that, I agree that it should work.
In the above rule, you use 10.1.1.57 and not 10.1.1.56 as in your OP, so verify the IP you want to redirect
Other than that, I agree that it should work.
All together, I am using 4 IPs on two computers:
10.1.1.12 on my server
10.1.1.13 on my server, used to redirect.
10.1.1.56 on my laptop.
10.1.1.57 on my laptop, used to redirect.
There are two set ups I used to test:
request 10.1.1.13 which is redirected to 10.1.1.56, does not work
request 10.1.1.57 which is redirected to 10.1.1.13, which works.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.