logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: multiple servers
Author
iaintarrant



Joined: 29 Nov 2016
Posts: 4
Location: Australia

PostPosted: Wed 30 Nov '16 0:23    Post subject: multiple servers Reply with quote

Hello everyone,

About 18 months ago I setup my email server on a seperate machine to my main server because it was the only thing that worked at the time. This webmail is setup on nginx.

Since then I have a new server capable of multiple virtual servers, so I have copied the mail server to a virtual machine and all is good.
However, On my new server I have a virtual container setup specifically for a web server and it only seems to work for a subdomain I setup on it, with nat forwarding through port 8080 to that ip:80. On the mail server there is roundcube webmail setup which I would like to keep.

Basic setup:
mail server > example.com/mail >external ip:80/mail directs to this
web server > subdomain.example.com > external ip:8080 points to this
these work fine, but I would like to use example.com as my main website, and get rid of port 8080.

Can a redirect be put in place on the new webserver that points to the mail directory on the mail server so I can point all web traffic to the one server?
Back to top
iaintarrant



Joined: 29 Nov 2016
Posts: 4
Location: Australia

PostPosted: Wed 30 Nov '16 15:38    Post subject: Reply with quote

So I thought i could do a redirect using the .htaccess file in a subdomain in the web server. I have altered the router to point all web traffic to it on port 80. That works fine. I have a basic html file there that loads upon using the subdomain. But the .htaccess file either doesn't load or is configured incorrectly.
My thought was to mirror the mail server on this subdomain. Maybe I'm doing it wrong. Any help is appreciated.

Iain
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7306
Location: Germany, Next to Hamburg

PostPosted: Wed 30 Nov '16 18:49    Post subject: Reply with quote

It can be done in a single vhost

Code:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so

<VirtualHost *:80>
   ServerName example.com

   DirectoryIndex index.php

   CustomLog "C:\nul" common

   DocumentRoot "/Users/jblond/htdocs"
   <Directory "/Users/jblond/htdocs">
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
   </Directory>

   ProxyPass /mail http://192.168.100.1/mail
   ProxyPassReverse /mail http://192.168.100.1/mail
</VirtualHost>
Back to top
iaintarrant



Joined: 29 Nov 2016
Posts: 4
Location: Australia

PostPosted: Thu 01 Dec '16 2:56    Post subject: Reply with quote

Sorry, probably should have mentioned it. I am running a Proxmox server with Debian containers. So the modules don't all line up and I get config test errors.

I have swapped out modules/mod_proxy.so for mods-available/proxy.load, modules/mod_proxy_connect.so for mods-available/proxy_connect.load and modules/mod_proxy_http.so for mods-available/proxy_http.load

This has not worked and I am wondering what other changes will need to be made to this code for a Debian system.

The .load files point to /usr/lib/apache2/modules/mod_proxy_connect.so
Back to top
iaintarrant



Joined: 29 Nov 2016
Posts: 4
Location: Australia

PostPosted: Thu 01 Dec '16 5:49    Post subject: Reply with quote

Ok so the proxy is working, traffic is being redirected to the nginx server on another ip. However, there are rewrite rules being applied to the incoming url and as such something is not working. As it now seems an nginx problem, if no-one can help me I'll post this new problem elsewhere.

The roundcube mail is being served by nginx which was setup by iRedmail. The .conf file for nginx listens on port 80 and then rewrites the url to
location ~ ^/mail { rewrite ^ https://$host$request_uri?; }
The ssl side listens on port 443 and here is the code for that
# Roundcube webmail
location ~ ^/mail(.*)\.php$ {
include fastcgi_params;
fastcgi_pass php_workers;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /opt/www/roundcubemail$1.php;
}

location ~ ^/mail(.*) {
alias /opt/www/roundcubemail$1;
index index.php;
}

location ~ ^/mail/(bin|SQL|README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ { deny all; }

When entering the address mail.example.com it gets rewritten to https://mail.example.com/mail (which means that nginx has been given the url and has modified it to suit ssl) but the response is "The site cannot be reached"
If I remove the https:// rewrite rule is gives a 500 internal server error, so the webmail setup must require ssl to function correctly.

Any ideas?
Back to top


Reply to topic   Topic: multiple servers View previous topic :: View next topic
Post new topic   Forum Index -> Apache