Answer the question
In order to leave comments, you need to log in
How to make nginx work outside of localhost on docker?
I create a docker container, everything seems to be OK, however, despite the correct nginx configuration, the site opens only through localhost, and
test.conf does not open in the normal way:
server {
index index.php;
server_name test.dev;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/frontend/web;
listen 80;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php$is_args$args;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
# deny accessing php files for the /assets directory
location ~ ^/assets/.*\.php$ {
deny all;
}
location ~* /\. {
deny all;
}
}
nginx:
# используем последний стабильный образ nginx
image: nginx:latest
# маршрутизируем порты
ports:
- "80:80"
- "443:443"
# монтируем директории, слева директории на основной машине, справа - куда они монтируются в контейнере
volumes:
- ./hosts:/etc/nginx/conf.d
- ./www:/var/www
- ./logs:/var/log/nginx
# nginx должен общаться с php контейнером
links:
- php
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question