【docker】记录一次nginx启动失败的检测

简介: 【docker】记录一次nginx启动失败的检测

周日领导说docker nginx起不来了,导致jira域名映射失败,记录一下解决过程

操作

首先nginx不是自己部署,要先启动一下

docker start nginx

发现打印出了nginx 但是 docker ps 发现 nginx还是启动失败

于是准备查看日志

docker logs -f nginx

报了一堆错误,也不知道是什么时候打的日志,后来解决之后猜测是因为配置文件为空的原因,因为没有找到event模块

所以首先看一下nginx的容器信息

docker inspect nginx

找到挂载信息了,可以看看配置文件,发现 /usr/nginx/conf 里面没有配置文件,这个时候就应该找到了问题;可是运维同学在查询问题的时候创建了一个空的nginx.conf,我没有打开配置文件

后来在老大的提醒下打开了配置文件发现是空的,然后就对配置文件进行了修改

先找了一个默认的nginx.conf的配置

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

然后docker start nginx 发现可以启动了

接下来增加正确的jira配置

   location / {
  proxy_pass http://192.168.1.111:8080;
   proxy_redirect          off;  
                proxy_set_header        Host $host:$server_port;   ##重点在$server_port
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_max_temp_file_size 0;
                proxy_connect_timeout 90;
                proxy_send_timeout 90;
                proxy_read_timeout 90;
                proxy_buffer_size 4k;
                proxy_buffers 4 32k;
                proxy_busy_buffers_size 64k;
                proxy_hide_header Vary;
                proxy_set_header Accept-Encoding '';
                proxy_set_header Referer $http_referer;
                proxy_set_header Cookie $http_cookie;
        }

进入容器检测一下配置文件是否有问题

docker exec -it 容器id /bin/bash

nginx路径寻找 find / -name nginx

./nginx/sbin/nginx -t

检测发现少了一个}

:set nu

找到具体行,然后修复

ctrl +D  // 退出容器

启动nginx

docker restart nginx

结果

虽然解决的很慢 但是还是解决了问题,nginx单点也是有问题的,后期打算切换到多活的nginx,然后备份相关nginx文件

目录
相关文章
|
3天前
|
应用服务中间件 Linux nginx
Docker镜像-手动制作yum版nginx镜像
这篇文章介绍了如何手动制作一个基于CentOS 7.6的Docker镜像,其中包括下载指定版本的CentOS镜像,创建容器,配置阿里云软件源,安装并配置nginx,自定义nginx日志格式和web页面,最后提交镜像并基于该镜像启动新容器的详细步骤。
45 21
Docker镜像-手动制作yum版nginx镜像
|
3天前
|
应用服务中间件 nginx Docker
Docker镜像-基于DockerFile制作编译版nginx镜像
这篇文章介绍了如何基于Dockerfile制作一个编译版的nginx镜像,并提供了详细的步骤和命令。
47 17
Docker镜像-基于DockerFile制作编译版nginx镜像
|
3天前
|
NoSQL 关系型数据库 Redis
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
mall在linux环境下的部署(基于Docker容器),docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongodb、minio详细教程,拉取镜像、运行容器
mall在linux环境下的部署(基于Docker容器),Docker安装mysql、redis、nginx、rabbitmq、elasticsearch、logstash、kibana、mongo
|
3天前
|
应用服务中间件 Linux nginx
Docker镜像-基于DockerFile制作yum版nginx镜像
本文介绍了如何使用Dockerfile制作一个基于CentOS 7.6.1810的yum版nginx镜像,并提供了详细的步骤和命令。
36 20
|
7天前
|
前端开发 应用服务中间件 nginx
[译] 面向 React 和 Nginx 的 Docker 多阶段构建
[译] 面向 React 和 Nginx 的 Docker 多阶段构建
[译] 面向 React 和 Nginx 的 Docker 多阶段构建
|
18天前
|
应用服务中间件 Linux nginx
Linux虚拟机磁盘扩容、Docker容器磁盘满的问题、Docker安装nginx
这篇文章讨论了Linux虚拟机磁盘扩容的方法,包括外部配置、具体扩容步骤和扩容后的效果验证。同时,文章还涉及了Docker容器磁盘满的问题及其解决方法,如删除不必要的镜像和容器,以及调整Docker的安装路径。此外,还提到了意外情况的处理,例如误删除停止的容器后的应对措施。最后,文章还提供了使用Docker安装nginx的步骤和成功访问的截图。
Linux虚拟机磁盘扩容、Docker容器磁盘满的问题、Docker安装nginx
|
25天前
|
应用服务中间件 网络安全 nginx
运维专题.Docker+Nginx服务器的SSL证书安装
运维专题.Docker+Nginx服务器的SSL证书安装
33 3
|
15天前
|
应用服务中间件 Linux nginx
【Nginx 第二篇章】windwos、linux、docker-compose 安装 NGINX
在一节中,我们介绍了如何在Windows环境下安装Nginx,包括从官网下载稳定版压缩包、解压并直接运行`nginx.exe`启动服务,最后通过浏览器访问`http://localhost/`验证安装。第二节覆盖了Linux环境下的安装流程,首先安装必要依赖,接着利用包管理器安装Nginx,并通过`systemctl`或`service`命令启动,同样通过浏览器确认安装成功。第三节则展示了如何使用`docker-compose`轻松部署Nginx,通过编写`docker-compose.yml`文件定义服务和配置映射,最后执行`docker-compose up -d`后台启动容器。
22 0
|
22天前
|
Ubuntu 应用服务中间件 nginx
Docker 解析:如何将 Nginx 容器化并用作代理
Docker 解析:如何将 Nginx 容器化并用作代理
31 0
|
25天前
|
应用服务中间件 nginx Docker
Docker 安装 Nginx
Docker 安装 Nginx
61 0
下一篇
DDNS