R
R
RSalo2019-05-29 05:16:24
Nginx
RSalo, 2019-05-29 05:16:24

Change nginx server_name in docker container?

Hello. After the vagrant, I try to delve into the docker and can’t enter it in any way. Here I have let's say nginx nginx_test.conf


server {
listen 80;
server_name localhost1.loc;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

and the docker docker-compose.yaml itself:

version: "3.3"
services:
nginx:
image: nginx
ports:
- "80:80"
volumes:
- "./nginx/nginx_test.conf:/etc/nginx/conf.d/default.conf"

It looks like nothing special, but why does localhost still open instead of localhost1.loc after docker-compose up? It seems that volumes binding occurs after the launch of nginx itself, and not during its initialization. Tell me, maybe I didn’t read something in the docs?
PS
There are suspicions that inside the container everything can work fine, just the container will give everything that is somehow tied to the 80th port in it and the point is in the configs of each service themselves. It is possible that when any service is initialized, it is assigned localhost during port forwarding. As if inside the container there will be my localhost1.loc, and the service itself will be localhost, but this is not accurate.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OnYourLips, 2019-05-29
@RSalo

The nginx, which is in the docker and belongs to the application, usually listens on http to everything and gives its application.
And domains, SSL, etc. already winding up on an external nginx, which is outside the docker. With proxy pass to docker.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question