Answer the question
In order to leave comments, you need to log in
How to make it so that when visiting domen1.tld:8080, the content from domen2.tld:8080 is returned?
The task is this, you need to make it so that when the browser requests an address, for example domen1.tld:8080 , what is on a different physical computer / address, for example domen2.tld:8080 , is returned .
Given:
- 2 computers (both have routers and Debian OS);
- the first IP is static, the second is dynamic;
— domain name ( domen1.tld ), which is linked to the first server (it is the main one and must be linked to the first server, so do not offer the option of linking it to the second server or transferring the service from the second computer to the first one) and the second domain name ( domen2.tld ) - dynamically updated by the second computer;
- a certain server is running on the second computer, with the main domain, or rather subdomains, registered as SRV and CNAME records.
You need to somehow make it so that when you connect to the main root domain - domen1.tld with port 8080 , the connection goes to the second computer and, accordingly, that the data is given to the second server on which port 8080 is listening - domen2.tld:8080 .
- Tried through SRV records, like:
_http._tcp.domen1.tld. IN SRV 0 5 8080 domen2.tld.<br/>
server {<br/>
listen 8080;<br/>
server_name domen1.tld <a href="http://www.domen1.tld;">www.domen1.tld;</a><br/>
location / {<br/>
proxy_pass <a href="http://domen2.tld">domen2.tld</a>:8080/;<br/>
proxy_redirect off;<br/>
proxy_set_header Host $host:$proxy_port;<br/>
proxy_set_header X-Real-IP $remote_addr;<br/>
}<br/>
}<br/>
Answer the question
In order to leave comments, you need to log in
Browsers do not support SRV
You need a banal reverse proxy. NginX will do.
1. Of course, the first thing that comes to mind is reverse proxy. Nginx was advised, you can do it with Apache, and with Squid - in general, there is a choice. Minus: for the second server, all requests will come as if from the first one, and you will have to look at the real addresses in the proxy logs on the first one.
2. At the "lower" level: NAT. You need a direct link between the servers (as an option, its imitation using a VPN). The first server NATs all packets arriving on the tcp/8080 port to the second one, and on the second web server, hanging on 8080, a virtual host is configured with the domain that users will access, and the rule in RPDB is that all packets coming from the internal address , go through the first one.
The second option is hemorrhoids, but it is quite efficient. I would do it first.
CNAME will only help here if you want to make servers with different names, because in any case, for end users, domen1 and domen2 will point to the same address. It is possible to make the second CNAME the first.
SRV is not used in HTTP.
If you tell me why you need this, maybe a more normal solution will be offered.
If not sir
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question