Get the App
SLTechnology News&Howtos  ›  Servers  › 

Resolution of problems that cannot be accessed after docker nginx is running

Shulou Source: shulou.com Published: 2022-06-02 03:18:15 10月02日 Update

# # 1

Recently, I am learning docker deployment. At first, I intend to docker nginx first.

Customize the configuration according to the official docker image introduction.

After copying the official nginx.conf, some customizations have been added, mainly shielding default.conf and the include folder sites-available.

# include / etc/nginx/conf.d/.conf;include / etc/nginx/sites-available/

Official original configuration

User nginx;worker_processes 1 errorists log / var/log/nginx/error.log warn;pid / var/run/nginx.pid;events {worker_connections 1024;} http {include / etc/nginx/mime.types; default_type application/octet-stream Log_format main'$remote_addr-$remote_user [$time_local] "$request"'$status $body_bytes_sent "$http_referer"'"$http_user_agent"$http_x_forwarded_for"; access_log / var/log/nginx/access.log main; sendfile on; # tcp_nopush on; keepalive_timeout 65; # gzip on; include / etc/nginx/conf.d/*.conf;}

New docker-compose.yml simply specify images, name, port, and mount local files instead of the default

Version: '3'services: nginx-proxy: image: nginx container_name: nginx ports:-8081 version 80 volumes: -. / nginx/nginx.conf:/etc/nginx/nginx.conf:ro

# # 2

After running docker-compose up, it has been stuck in attaching to nginx, and the browser cannot access the port address.

Starting nginx... Done

Attaching to nginx

I don't know what the problem is. After looking up the data, I found that the tty parameter can be used for debugging.

Modify docker-compose.yml to add a configuration tty:true.

Docker exec-it nginx / bin/bash

Found that after removing the default default.conf, no other configuration files were added, and the previous sites-available folder was empty.

# # 3

You cheated yourself and added it.

-. / nginx/sites-available:/etc/nginx/sites-available:ro

And add a configuration file to sites-available.

/ etc/nginx/sites-available# lsdefault.conf

After running, the access to the port address is finally normal.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Tags: File configuration official port run address folder question content parameter name that is browser data image learning help support browse Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology macOS MySQL Redmi Shulou Information