Author Topic: Redirect Url Web Server  (Read 7104 times)

zentyaltester

  • Zen Apprentice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Redirect Url Web Server
« on: February 02, 2014, 12:07:31 pm »
I want redirect an http request from my zentyal server to an internal apache server.

Therefore I created an Virtual Host in the Web Server section.

Virtual Host name: undesired.example.com

I tried something like this:

<VirtualHost *:80>
  ServerName undesired.example.com

  Redirect / http://internalnet.lan/
</VirtualHost>

And many other things but i got only errors.

Whats the correct configuration for the file '/etc/apache2/sites-available/user-ebox-<domain>/'

peterpugh

  • Guest
Re: Redirect Url Web Server
« Reply #1 on: February 02, 2014, 12:52:09 pm »
http://httpd.apache.org/docs/current/rewrite/remapping.html

The rewrite rule might be needed though as I can't remember if state and source page work with a simple static declaration.

Port forwarding is not an answer if you are going to serve from the same port.

So I guess best way is to post those errors.

Start by just trying to access the source website from the Zentyal machine and work your way up.

PS http://doc.zentyal.org/en/appendix-c.html#advanced-service-customization

Don't edit the config files directly.
« Last Edit: February 02, 2014, 12:59:42 pm by peterpugh »

christian

  • Guest
Re: Redirect Url Web Server
« Reply #2 on: February 02, 2014, 01:38:52 pm »
I want redirect an http request from my zentyal server to an internal apache server.

I'm not nitpicking but I'm afraid you misunderstand, unless I'm wrong with what you intend to achieve, what redirection would mean and provide.

What is not clear in your statement is whether you want to redirect requests from internal or from external.
- for internal clients accessing Zentyal, you can for sure redirect to internal web site, using permanent or temporary redirect (HTTP 301 or 302). You can also achive it using .htaccess.
- if goal is to provide access to internal web site from external users, then this is by no mean "redirect" but either port forwarding (if you want to handle it at network level but then it will act for any connection, whatever the URL) or reverse proxy running on Zentyal server.

You will find plenty of topics about reverse proxy if you use forum search feature.

zentyaltester

  • Zen Apprentice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Redirect Url Web Server
« Reply #3 on: February 02, 2014, 03:29:10 pm »

christian

  • Guest
Re: Redirect Url Web Server
« Reply #4 on: February 02, 2014, 03:54:02 pm »
where did you put this proxpass directive ? (So I assume your choice is Apache based reverse proxy isn't it?)

peterpugh

  • Guest
Re: Redirect Url Web Server
« Reply #5 on: February 02, 2014, 04:40:16 pm »
zentyaltester,

I am presuming you have read the advanced customisation and have created a stub or a hook to create the extra apache entries.

Then enable the proxy mod (a2enmod proxy)

Then restart apache

Check your logs.

Can't really tell you more as haven't used the proxy mod.
« Last Edit: February 02, 2014, 04:51:43 pm by peterpugh »

zentyaltester

  • Zen Apprentice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Redirect Url Web Server
« Reply #6 on: February 05, 2014, 06:57:39 pm »
Use Case: I type https://mymusic.externaldomain.de in my browser

This doesn't works:

File:
  /etc/apache2/sites-available/user-ebox-mymusic.externaldomain.de/000-default

Content:
  ProxyPass / http://mymusic.example.lan:4040/
  ProxyPassReverse / http://mymusic.example.lan:4040/

this redirects to the zentyal server(https://example.lan).


____________

Use Case: I type https://externaldomain.de/mymusic in my browser

This doesn't works:
File: /etc/apache2/sites-available/user-ebox-externaldomain.de/000-default
Content: ProxyPass /mymusic http://mymusic.example.lan:4040/
ProxyPassReverse /mymusic http://mymusic.example.lan:4040/

results in a wrong url.
https://externaldomain.de/login.html but it must be https://externaldomain.de/mymusic/login.html



peterpugh

  • Guest
Re: Redirect Url Web Server
« Reply #7 on: February 05, 2014, 08:00:25 pm »
Sorry for sounding dumb but I have years of practice...


First of all can you reach the destination website via the browser on the zentyal server.

IE check that the redirect will hit something?

 

robb

  • Guest
Re: Redirect Url Web Server
« Reply #8 on: February 05, 2014, 08:01:09 pm »
Call me stupid, but why don't you just add a DNS entry for mywiki.example.de in your local DNS and install the wikisoftware in a vhost called mywiki.example.de
Then http://mywiki.example.de is accessible from both external and internal network, (provided you have a DNS record for mywiki.example.de for your domain at the authoritative DNS server for the domain)

Or add the DNS entry which points to the Apache webserver on your lan....

anyway, I think you catch my drift...
« Last Edit: February 05, 2014, 08:02:48 pm by robb »

zentyaltester

  • Zen Apprentice
  • *
  • Posts: 19
  • Karma: +0/-0
    • View Profile
Re: Redirect Url Web Server
« Reply #9 on: February 06, 2014, 06:55:19 pm »
All my Servers are VMs and running on a kvm host(Root Server, only ssh).

There are two networks:

192.168.122.0/24 --> Nat
192.168.100.0/24 --> Isolated & no DHCP, zentyal makes dhcp and gateway

The Zentyal Server has the addresses:
eth0 = 192.168.122.2 (zentyal.example.lan)
--> This marked as external. All desired port are forwarded to this vm. Included the port 80 & 443

eth1 = 192.168.100.2
--> This is the internal network. Vms inside the network 192.168.100..0/24 are not accessible from the kvm host and the internet. The zentyal acts as dhcp server and gateway for this network.

The domain suffix *.lan denotes that is an internal network and the suffix *.de denotes the domain as external.

I am running serveral VMs in the isolated Network which are connected over zentyal server. Everythings works fine.

One VM acts as Mediawiki server(192.168.100.112, http://mywiki.example.lan).

I can request the wiki from the internal network.

Now I want reach my wiki from outside my internal network.
Therefore I configured my server as follow:
"Web Server" Section I created a new Virtual Host named http://mywiki.example.de. This is the address which i want to use to call the wiki over the internet.

If I want to forward my http request from 192.168.122.2 to http://mywiki.example.lan. I need to change the following file:

/etc/apache2/sites-available/user-ebox-mywiki.example.de/000-default
ProxyPass / http://mywiki.example.lan/
ProxyPassReverse / http://mywiki.example.lan/

and it happens the same behavior like explained in my last post?

why it is not possible to forward a web url root(like http://mywiki,example.de) to an internal web server like http://mywiki.example.lan(Document root in apache is: /) ??
because this:

/etc/apache2/sites-available/user-ebox-mywiki.example.de/000-default
ProxyPass /mywiki http://mywiki.example.lan/mywiki
ProxyPassReverse /mywiki http://mywiki.example.lan/mywiki

works perfectly.

I hope I could make my problem understandable.

My apache configuration is wrong and I need the right one.

Sorry the idea with the dns is not possible and there are no errors.
« Last Edit: February 06, 2014, 09:35:59 pm by zentyaltester »

peterpugh

  • Guest
Re: Redirect Url Web Server
« Reply #10 on: February 06, 2014, 10:17:13 pm »
I don't think we can use redirect or rewrite rules or htaccess as they just cause a browser refresh which can not access the internal webserver.

Bit like <meta http-equiv="Refresh" content="8;URL=http:// www.example.com/somepage.html"> the browser just isn't going to find it.

http://blog.dimaj.net/2011/02/howto-proxy-your-internal-websites-via-a-single-apache2-server

http://www.integratedwebsystems.com/2010/06/multiple-web-servers-over-a-single-ip-using-apache-as-a-reverse-proxy/

The first link has an extra that I didn't know there was a difference.

sudo a2enmod proxy_html

what that is ? as I thought it was just sudo a2enmod proxy

« Last Edit: February 06, 2014, 10:23:28 pm by peterpugh »