V
V
Vadim Kosolapov2019-04-26 16:39:55
Nginx
Vadim Kosolapov, 2019-04-26 16:39:55

How to configure docker to work from under a domain on a local machine?

Good afternoon! I am developing an online store, I need to integrate payment, and for this you need to have a domain.
I have docker-compose with nginx and php-fpm:

version: '3'
services:
  shop-nginx:
    build:
      context: ./docker
      dockerfile: nginx.docker
    volumes:
      - .:/app
    depends_on:
      - shop-php-fpm
    ports:
      - "8083:80"
  shop-php-fpm:
    build:
      context: ./docker
      dockerfile: php-fpm.docker
    volumes:
      - .:/app
      - ./docker/php-fpm/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
    tty: true

Whole file: https://github.com/k0v4back/shop-symfony/blob/mast...
And there are settings for nginx:
server {
    listen 80;
    index index.php index.html;
    root /app/public;

    client_max_body_size 50m;

    location / {
        try_files $uri /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass shop-php-fpm:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

Question: what needs to be changed in my configs to make the site work under a domain, for example, k0v4-shop.com on a local machine?
PS
I already tried to set up server_name in nginx and then set the address in /etc/hosts on my machine, but still nothing happened.
Tell me in which direction to move, what to google or what resources to read in order to set everything up and understand how it works.
PSS
The code is on github: https://github.com/k0v4back/shop-symfony

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
andrei_pro, 2019-04-26
@Ynicum_navern

Add to /etc/hosts:
127.0.0.1 yourdomain.local
In docker port 80 outside if you want to open yourdomain.local
ports:
- "80:80"
server_name is not necessary if you have one host.

S
sl0, 2019-04-26
@sl0

Is the site reachable by ip?
In general, I would change com to test. It is possible that the browser is trying to look it up via dns.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question