PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, June 24, 2022

[FIXED] How to setup apache 2 reverse proxy to forward different domain and pretend as that domain name?

 June 24, 2022     apache, http-headers, reverse-proxy     No comments   

Issue

I am using Debian and apache2, I don't know if it is possible to use apache to reverse proxy from one domain to another domain, but the backend server behind the latter server still consider the requesting URL is of the latter?

For example if you visit https://www.example.com/index.html, the request will forward to https://www.example.org/index.html, but in the backend server of www.example.org still think the requesting URL is https://www.example.org/index.html, not https://www.example.com/index.html

I think I need to change the X-Forwarded-Server header in the apache proxying, but I don't know how. Any help would be highly appreciated.


Solution

The behavior you describe is the default behavior:

If example.com has the following configuration:

ProxyPass / http://example.org/

And I go to http://example.com/, then example.org will see the following request (check the Host header):

GET / HTTP/1.1
Host: example.org
[...]
X-Forwarded-For: <client IP address>
X-Forwarded-Host: example.com

With ProxyPreserveHost On, you change this behavior and get

GET / HTTP/1.1
Host: example.com
[...]
X-Forwarded-For: <client IP address>
X-Forwarded-Host: example.com

Unless example.org uses the X-Forwarded-Host header to decides what content to serve, you're good.



Answered By - David Duponchel
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing