S
S
susnake2015-03-03 09:18:00
Apache HTTP Server
susnake, 2015-03-03 09:18:00

Is it possible to redirect packets so that 2 sites open?

Good afternoon.
There is a mx.example.com domain, which corresponds to an external ip 152.56.89.52, when opening the domain, we get to the web version of the exchange mailbox (internal IP 192.168.5.2). https://mx.example.com/owa.
There is another server under ubuntu 14.04 with apache2 installed (internal IP 192.168.5.3).
I wrote in apache2.conf:

<VirtualHost 192.168.5.3>
  ServerAdmin [email protected]
  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>

When going to data.example.com, we get into the web version of the exchange if the 80th port on 192.168.5.2 is open on the router.
Is it possible to somehow make the 80th port work both for the server with the exchange and for the Linux server?
Previously, when I needed to host several sites on one Linux server, I configured VirtualHost and everything was fine. But I have not come across this. Maybe this is not a problem with apache2 and ubuntu, but with traffic redirection on the router? We have ZyXEL Keenetic Ultra.
On the hosting, the data.example.com subdomain is set up and exists.
h_1425363199_4093231_8e4ce47e6b.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2015-03-12
@susnake

  1. Switch to nginx on an owncloud server (either put it as another one, or put it 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;
        }
    }

    second in analogy
  3. abandon http in crawling https example for exchange (do not forget to put 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;
        }
    }

L
ldv, 2015-03-03
@ldvldv

You can reconfigure the port forwarding on the router to 192.168.5.3. And on apache reverse proxy for exchange.
www.jamescoyle.net/how-to/116-simple-apache-revers...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question