A
A
Anton Mashletov2018-02-16 17:42:52
Nginx
Anton Mashletov, 2018-02-16 17:42:52

Is there a way to get server_name inside a Docker container?

I need to make admin.localhost and localhost point to different webroots.
This is how it doesn't work:

server {
    listen 80;
    server_name: localhost
    index index.php;
    root /var/www/frontend/web;
}

server {
    listen 80;
    server_name: admin.localhost;
    index index.php;
    root /var/www/backend/web;
}

As I understand it, there is a completely different network inside the docker container and there is no localhost there, and in general, all domains are lost?
Now I remove server_name altogether and set different ports for these servers, and proxy using external nginx on the host - CRUTCH IMHO.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coder4web, 2018-02-16
@mashletov

A proxy is just a standard solution, as I understand it, I understood it in a neighboring topic.
For multiple vhosts use the nginx-proxy project .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question