L
L
lavAzza22016-07-02 22:13:26
Apache HTTP Server
lavAzza2, 2016-07-02 22:13:26

How to set up redirects to the site?

Next situation.
We have:
Router connected to the Internet,
Server 1
Server 2
Servers are connected to the router.
On router 80, port forwarded to server 1, 8080 forwarded to server 2.
On server 1 LAMP and the only useful resource is a directory accessible to users via http.
On the server 2 LAMP and a website.
I would like:
So that when accessing the 80 port of the router, the site of server 2 opens, but at the same time the directory of server 1 remains available at the same address.
How to set up forwarding? Maybe from server 1 to server 2? or make server 2 the main one and redirect it to server 1? Or in general somehow to connect the directory of the server 1 to the server 2? How to do it technically?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
A person from Kazakhstan, 2016-07-03
@LenovoId

how difficult did you come up with, but the usual options without difficulties are not an option?

<HTML>
  <HEAD>
    <META HTTP-EQUIV="REFRESH" CONTENT="1; URL=http://domain.ru">
  </HEAD>
  <BODY>
  </BODY>
</HTML>

<script language="JavaScript"> 
  window.location.href = "http://domain.ru"
</script>

K
Karim Kyatlottyavi, 2016-07-03
@constXife

The solution to your problem lies in the proxy plane. I have not hung around with apache for a long time, but on nginx it would look something like this.

server {
    listen 80;
    server_name server2;

    location /catalog {
        proxy_pass http://server1;
        proxy_redirect off;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
    }
}

It may be necessary to adapt the catalog code to such an environment.
And for Apache, try looking here - https://httpd.apache.org/docs/current/mod/mod_prox... or google it yourself on Russian-language sources.

L
lavAzza2, 2016-07-04
@lavAzza2

And so I did in the end (the first option). But in this case, the port number 8080 is displayed in the address. So, apparently, a temporary solution. Then it will need to be redone.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question