Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

# # 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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report