K
K
kvaks2021-08-02 16:55:21
go
kvaks, 2021-08-02 16:55:21

How to run several web scripts on 1 hosting, on different subdomains?

on a virtual host.
In particular interested in golang.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Mamonov, 2021-08-02
@kvaks

Write Go lang services that you need.
Each service listens on a different port.
Set up a web server, such as nginx, and set up virtual hosts that forward requests to Go lang services.
The nginx config will look something like this

server {
    listen *:80;
    server_name yourdomain1.com; # домен, который вам нужно
    ...
    location / {
        proxy_pass http://127.0.0.1:9000; # IP адрес и порт, на котором слушает сервис Go lang.
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

server {
    listen *:80;
    server_name yourdomain2.com; # домен, который вам нужно
    ...
    location / {
        proxy_pass http://127.0.0.1:9001; # IP адрес и порт, на котором слушает сервис Go lang.
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

S
Stanislav Bodrov, 2021-08-03
@jenki

How to run several web scripts on 1 hosting, on different subdomains?
You just run it and it works. It is possible without containers at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question