D
D
Dmitry2020-12-23 19:24:09
Nginx
Dmitry, 2020-12-23 19:24:09

How to change the address for working with web servers through docker?

There is macOS. It has Docker Desktop for Mac installed on it. It
uses a docker container with nginx
. The site started up fine at localhost/

But I need to change this address to my own.
I go inside the container and there in the file
nano /opt/docker/etc/nginx/vhost.conf
I write

spoiler
server {
  server_name crm.loc;

    root /var/www/app/public;

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

    location ~ ^/index\.php(/|$) {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;

        fastcgi_param APP_X_SHOP $http_x_shop;
        fastcgi_param APP_X_SESSION $http_x_session;

        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/index.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }

    # return 404 for all other php files not matching the front controller
    # this prevents access to other php files you don't want to be accessible.
    location ~ \.php$ {
        return 404;
    }

    error_log /docker.stderr;
    access_log /docker.stdout;
}


Then on the local machine in the file /etc/hosts I add
127.0.0.1 crm.loc

But it doesn't work. The site continues to work in the browser through localhost/

At what the same manipulations on ubunt helped solve my problem. But on a Mac, no. Tell me how to solve the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question