nginx启动失败如何解决

发布时间 - 2023-05-26 00:00:00    点击率:

操作

首先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 {
        # 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
        #    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
    #    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;

然后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  #   # Event  # docker  # jira  # 配置文件  # 也不  # 是因为  # 出了  # 少了  # 找了  # 这个时候  # 要先  # 看一下  # 就对 


相关栏目: 【 网站优化151355 】 【 网络推广146373 】 【 网络技术251813 】 【 AI营销90571


相关推荐: Python自动化办公教程_ExcelWordPDF批量处理案例  如何用VPS主机快速搭建个人网站?  用v-html解决Vue.js渲染中html标签不被解析的问题  C语言设计一个闪闪的圣诞树  Laravel如何自定义错误页面(404, 500)?(代码示例)  Laravel如何处理异常和错误?(Handler示例)  如何在云服务器上快速搭建个人网站?  如何在IIS中新建站点并配置端口与物理路径?  昵图网官网入口 昵图网素材平台官方入口  Laravel怎么在Controller之外的地方验证数据  再谈Python中的字符串与字符编码(推荐)  如何快速搭建高效WAP手机网站吸引移动用户?  ChatGPT怎么生成Excel公式_ChatGPT公式生成方法【指南】  Angular 表单中正确绑定输入值以确保提交与验证正常工作  Laravel安装步骤详细教程_Laravel环境搭建指南  iOS正则表达式验证手机号、邮箱、身份证号等  独立制作一个网站多少钱,建立网站需要花多少钱?  Midjourney怎么调整光影效果_Midjourney光影调整方法【指南】  常州企业网站制作公司,全国继续教育网怎么登录?  JavaScript中的标签模板是什么_它如何扩展字符串功能  ,交易猫的商品怎么发布到网站上去?  CSS3怎么给轮播图加过渡动画_transition加transform实现【技巧】  使用Dockerfile构建java web环境  Laravel Vite是做什么的_Laravel前端资源打包工具Vite配置与使用  Laravel如何创建自定义中间件?(Middleware代码示例)  清除minerd进程的简单方法  Win11怎么开启自动HDR画质_Windows11显示设置HDR选项  Laravel如何使用withoutEvents方法临时禁用模型事件  北京专业网站制作设计师招聘,北京白云观官方网站?  购物网站制作费用多少,开办网上购物网站,需要办理哪些手续?  php静态变量怎么调试_php静态变量作用域调试技巧【解答】  Laravel中的Facade(门面)到底是什么原理  Claude怎样写约束型提示词_Claude约束提示词写法【教程】  详解一款开源免费的.NET文档操作组件DocX(.NET组件介绍之一)  Laravel如何创建和注册中间件_Laravel中间件编写与应用流程  如何快速搭建二级域名独立网站?  如何彻底删除建站之星生成的Banner?  ,网页ppt怎么弄成自己的ppt?  Laravel事件监听器怎么写_Laravel Event和Listener使用教程  如何快速登录WAP自助建站平台?  原生JS实现图片轮播切换效果  googleplay官方入口在哪里_Google Play官方商店快速入口指南  为什么php本地部署后css不生效_静态资源加载失败修复技巧【技巧】  Edge浏览器提示“由你的组织管理”怎么解决_去除浏览器托管提示【修复】  logo在线制作免费网站在线制作好吗,DW网页制作时,如何在网页标题前加上logo?  Laravel如何处理JSON字段_Eloquent原生JSON字段类型操作教程  JavaScript Ajax实现异步通信  Laravel如何使用Scope本地作用域_Laravel模型常用查询逻辑封装技巧【手册】  如何在Tomcat中配置并部署网站项目?  如何在搬瓦工VPS快速搭建网站?