Z
Z
Zufero2019-09-24 15:32:32
System administration
Zufero, 2019-09-24 15:32:32

Forwarding from Domain to IP:port. How can I do that?

There is:
A server with a program that sits on a specific port (Let's say ip - 1.1.1.1, port - 10) (There is no access to it, no, in general, even iptables can not be changed)
Domain (Let's say example.com)
What you need: so that when when going to example.com, the user was redirected to 1.1.1.1:10, all options are considered, even the most crutch, inconvenient, etc.
If possible, explain in simple terms, because I am not strong in system administration.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
fdroid, 2019-09-24
@fdroid

Raise nginx, set up a virtual host in proxy mode, something like this:

server {
    listen 80;
    server_name example.com;
    access_log /var/log/nginx/example.com-access.log;
    error_log /var/log/nginx/example.com-error.log;
 
location / {
    proxy_pass http://1.1.1.1:10;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    }
}

Naturally, nginx must be accessible from the Internet via IP, i.e. The nginx IP must be white real or the router must have such an IP and port 80 must be forwarded to the internal IP of the nginx server.
In the dns settings of the domain registrar, you need to create an A-record for the example.com domain, which will correspond to the white IP on which nginx is available from the Internet.

S
SagePtr, 2019-09-24
@SagePtr

Establish a web server on port 80, and then transfer everyone to the HTTP Location header http://1.1.1.1:10/
. Or use the web server as a reverse proxy, proxy it to the samehttp://1.1.1.1:10/

A
Artem @Jump, 2019-09-24
Tag

It is impossible in principle. There are no alternatives and there cannot be.
Network resources are accessed by IP address.
A domain is simply a name associated with an IP address.
You make a DNS query for a domain name, it returns you an IP address.
The domain name has nothing to do with the port.
When going to example.com, the user will be redirected to 1.1.1.1
And when going to example.com:10, the user will always be redirected to 1.1.1.1:10
Describe the task in more detail - what exactly do you want to do. Most likely you need a reverse proxy. For example Nginx.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question