Is it possible to redirect packets that would have opened 2 sites?

Good afternoon.
A domain mx.example.com, which corresponds to the external ip 152.56.89.52 when you open the domain get on the web version of your mailbox exchange (internal IP 192.168.5.2). https://mx.example.com/owa.
There is another ubuntu server 14.04 with installed apache2 (internal IP 192.168.5.3).
In apache2.conf prescribed:
<virtualhost 192.168.5.3>
 ServerAdmin root@sexample.com
 ServerName data.example.com
 DocumentRoot /var/www/owncloud
 ErrorLog /var/log/data.example.com-error_log
 TransferLog /var/log/data.example.com-access_log
</virtualhost>

During the transition to data.example.com get to the web version of exchange if the router is open 80th port on 192.168.5.2.
Is there a way to do that would be 80-th port worked for a server exchanges for a Linux server?
Before when I had Linux on a single server to host multiple sites, I did not configure VirtualHost and it was great. But with that I encountered. Maybe the problem is not with apache2 and ubuntu, and traffic redirection on the router? We have ZyXEL Keenetic Ultra.
Hosting subdomain data.example.com routine exists.
h_1425363199_4093231_8e4ce47e6b.png
September 19th 19 at 00:03
2 answers
September 19th 19 at 00:05
Solution
  1. Go to nginx on the server owncloud (or put as another, or put on a separate server)
  2. Create nginx configs for both sites
    server {
     listen 80;
     server_name data.exemple.com;
    
     if ($http_host ~ "(?i)(data\.exemple\.com)$") {
     rewrite ^(.*) /web/$1 last;
    }
    
     location /web// {
     proxy_pass http://data.exemple.com;
     proxy_set_header Host $Host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Host $server_name;
     proxy_read_timeout 500;
    }
    
     location / {
     root /usr/share/nginx/html;
     index index.html index.htm;
    }
    
     error_page 500 502 503 504 /50x.html;
     location = /50x.html {
     root /usr/share/nginx/html;
    }
    }

    the second anologii

  3. to unsubscribe from http to https crawling example for exchange (don't forget to put the certificates in /etc/nginx/conf.d/cert/)
    server {
     listen 443;
    
     ssl on;
     ssl_certificate /etc/nginx/conf.d/cert/mail.crt;
     ssl_certificate_key /etc/nginx/conf.d/cert/mail.key;
     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
     server_name mx.example.com;
    
     #charset koi8-r;
     #access_log /var/log/nginx/log/host.access.log main;
    
     if ($http_host ~ "(?i)(mx\.example\.com)$") {
     rewrite ^(.*) /web/$1 last;
    }
    
     location /web// {
     proxy_pass https://mx.example.com;
     "proxy_redirect" off;
     proxy_set_header Host $Host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Host $server_name;
     proxy_read_timeout 500;
    }
    
     location / {
     root /usr/share/nginx/html;
     index index.html index.htm;
    }
    
     error_page 500 502 503 504 /50x.html;
     location = /50x.html {
     root /usr/share/nginx/html;
    }
    }


Thank you! - Jakob.Harvey22 commented on September 19th 19 at 00:08
September 19th 19 at 00:07
You can reconfigure on the router, forwarding ports on 192.168.5.3. And apache reverse proxy for exchange.
www.jamescoyle.net/how-to/116-simple-apache-revers...
Thank you. Take a look. - Jakob.Harvey22 commented on September 19th 19 at 00:10

Find more questions by tags Ubuntu ServerMicrosoft ExchangeApacheZyXEL