LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 05-26-2021, 01:49 PM   #1
SlackCoder
Member
 
Registered: Nov 2020
Posts: 40

Rep: Reputation: Disabled
Apache ProxyPass and redirects


Hi,

Any knowledgeable Apache users here? I am having trouble with a virtual host setup to proxy to and from a locally running application hosted on a different internal port. Everything is fine until the application tries to redirect to an external domain.

When, for example, the application tries to redirect to some.otherhost.com/page.html it is instead redirected to some.host.com/page.html where some.host.com is the application's virtual host. Any ideas?

thanks

```
<VirtualHost _default_:443>
ServerName some.host.com

<location />
ProxyPreserveHost On
ProxyPass http://127.0.0.1:8080/
ProxyPassReverse /
RequestHeader add "X-Forwarded-Proto" "https"
</location>
...
</VirtualHost>

```
 
Old 05-26-2021, 02:20 PM   #2
MDKDIO
Member
 
Registered: Mar 2004
Location: Sweden
Distribution: Slackware 15
Posts: 521

Rep: Reputation: 187Reputation: 187
If I remember correctly, I had it set up with:
ProxyPass "/" "http://127.0.0.1:8080"
ProxyPassReverse "/" "http://IP_address:_port" minus the _

But I could be wrong, my memory is not what it used to be
 
1 members found this post helpful.
Old 05-26-2021, 04:43 PM   #3
SlackCoder
Member
 
Registered: Nov 2020
Posts: 40

Original Poster
Rep: Reputation: Disabled
The problem is this configuration changes -all- redirection domains to 'http://IP_address:_port', and not just some.host.com which I would expect.
 
Old 05-27-2021, 01:39 AM   #4
MDKDIO
Member
 
Registered: Mar 2004
Location: Sweden
Distribution: Slackware 15
Posts: 521

Rep: Reputation: 187Reputation: 187
Is there something in httpd.conf regarding redirect?
 
Old 05-27-2021, 02:03 AM   #5
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,097

Rep: Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174Reputation: 4174
Quote:
Originally Posted by SlackCoder View Post
The problem is this configuration changes -all- redirection domains to 'http://IP_address:_port', and not just some.host.com which I would expect.
could it be because you specified the block as
Code:
<VirtualHost _default_:443>
instead of
Code:
<VirtualHost some.host.com:443>
?
 
1 members found this post helpful.
Old 05-27-2021, 02:17 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by SlackCoder View Post
The problem is this configuration changes -all- redirection domains to 'http://IP_address:_port', and not just some.host.com which I would expect.
This happens because some.host.com is also the default vhost. So when visiting http://IP_address:_port you'll see the backend application.

Create another vhost to be used as the default, so the reverse proxy should work only when you visit some.host.com. I.e. use something like this:
Code:
<VirtualHost _default_:*>
    DocumentRoot "/svr/httpd/htdocs"
</VirtualHost>

<VirtualHost *:443>
ServerName some.host.com

<location />
ProxyPreserveHost On
ProxyPass http://127.0.0.1:8080/
ProxyPassReverse /
RequestHeader add "X-Forwarded-Proto" "https"
</location>
...
</VirtualHost>
 
1 members found this post helpful.
Old 05-27-2021, 11:10 AM   #7
SlackCoder
Member
 
Registered: Nov 2020
Posts: 40

Original Poster
Rep: Reputation: Disabled
Thanks for the help all

It worked once I used the same url for ProxyPass as for ProxyPassReverse.

```
ProxyPass http://127.0.0.1:8080/
ProxyPassReverse http://127.0.0.1:8080/
```
 
  


Reply



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
[SOLVED] proxypass and proxypassreverse config in apache indraindrajit71 Linux - Newbie 1 09-05-2013 02:51 AM
Apache ProxyPass doubt (ubuntu 6.10, apache 2.0) Carlos2dub Linux - Server 1 05-28-2008 03:43 AM
Apache ProxyPass/VirtualHost question lil_drummaboy Linux - Networking 2 11-10-2004 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 04:45 PM.

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