I
I
IvanKalinin2017-02-18 10:10:23
Nginx
IvanKalinin, 2017-02-18 10:10:23

How to change localhost to domain in nginx docker-compose container?

All good time.
Can you tell me how you can use your domain name instead of 'localhost' ?
Here is the basic configuration:
docker-compose.yml

version: '2'
services:
    web:
        build:
            context: ./
            dockerfile: web.docker
        volumes:
            - ./:/var/www/html
        ports:
            - "80:80"
        links:
            - app
    app:
        build:
            context: ./
            dockerfile: app.docker
        volumes:
            - ./:/var/www/html

vhost.conf
server {
    listen 80;
    index index.php index.html;
    root /var/www/html/public;

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

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

web.docker
FROM nginx:1.10

ADD ./vhost.conf /etc/nginx/conf.d/default.conf
WORKDIR /var/www/html

app.docker
FROM php:7-fpm

RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \
    && docker-php-ext-install mcrypt pdo_mysql

WORKDIR /var/www/html

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mureevms, 2017-02-18
@mureevms

Insert a line in the first block of the vhost.conf file
And yes, docker has nothing to do with it, you just don't have nginx configured.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question