I mounted Laravel on port 80 in Docker and this is my service in docker-compose.yml
webserver:
image: nginx:alpine
container_name: webserver
restart: unless-stopped
tty: true
ports:
- "8000:80"
- "8443:443"
volumes:
- ./:/var/www/docker/example/api
- ./nginx/conf.d/:/etc/nginx/conf.d/
I want to mapping 8000 port from ubuntu with 80 on docker that you see is done.
and the site comes up with this address http://ip_server:8000
I want to come up with the domain name of the site without entering the port
server {
listen 80;
index index.php index.html;
server_name example.com;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/docker/khesarat/api/public;
location ~ .php$ {
try_files $uri =404;
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;
}
}
2
Answers
If I am not confused, you would have to map it to
80
, and then edit yourhost
file (depends on what OS you are in) and add127.0.0.1 example.com
and it will automatically resolve to it.In this case and what I have done in my case is to run another
nginx
container listening on port80
. Addnginx
andwebserver
containers to the same network, then you should see what you want.Do as below:
docker network create NAME
domain.conf
file like this:docker-compose.yml
to:In this case you also can remove
ports
mapping directive from yourdocker-compose
file since it’s not needed.