Z
Z
Zakhar Skorokhodov2015-08-17 01:59:00
Domain Name System
Zakhar Skorokhodov, 2015-08-17 01:59:00

How to organize a redirect from domen.me:port to sub.domen.me for different services?

Given:
1) Domain registered in nic.ru;
2) Account on digitalocean. DNS's DO are registered in settings of the domain.
3) Mini-server at home running LinuxMint (aka work computer)
4) The following are already installed on the server:
a) transmission-daemon: 9091
b) gitlab: 9000
c) wiki: 9090
d) nginx: 80
5) Can be installed anything...
Task:
Organize addressing by subdomains for services, i.e.
1) For GIT domen.me:9000 -> git.domen.me
2) Transmission domen.me:9091 -> torrent.domen.me
3) Wiki domen.me:9090 -> wiki.domen.me
4) Any service domain.me:any_port -> any_service.domen.me

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-08-17
@edinorog

it is not necessary to fence a rake. if you need to have access to work with computers within the local network, then it's easier to raise vpn. and through vpn already go to everything you need

A
Andrew_Shtein, 2015-08-17
@Andrew_Shtein

"domain.me" is an identifier that can be converted to an ip address. When you access "domain.me" by the browser, the browser actually calls "domain.me:80" since 80 is the default port for the http protocol.
For one IP address, only one program can occupy one port at a time. Therefore, when several domains are hosted on the same machine, they put a proxy web server (nginx, for example), which will "listen" on the 80th port, and the rest of the web servers put "listen" on other ports (for example, 9000, 9091 , 9090), because 80 is busy. The proxy web server looks at which domain the request is coming from and forwards the request to the appropriate port.
Now back to your problem. As far as I understood, then "domen.me", "git.domen.me", "torrent.domen.me", "wiki.domen.me", etc. are converted to the same ip address?
In this case, if these are all http services, and by "git.domen.me" you meant "git.domen.me:80", then you need to write something like this in the nginx settings:

server{
  server_name git.domen.me;
    location / {
    proxy_pass http://127.0.0.1:9000;
  }
}
server{
  server_name torrent.domen.me;
    location / {
    proxy_pass http://127.0.0.1:9091;
  }
}
server{
  server_name wiki.domen.me;
  location / {
    proxy_pass http://127.0.0.1:9090;
  }
}
server{
  server_name any_service.domen.me;
  location / {
    proxy_pass http://127.0.0.1:any_port;
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question