How to solve nginx startup failure

王林
Release: 2023-05-26 19:55:38
forward
3549 people have browsed it

Operation

First of all, nginx is not deployed by itself, you need to start it first

docker start nginx
Copy after login

How to solve nginx startup failure

I found that nginx was printed, but docker ps found that nginx still failed to start

So I prepared to check the log

docker logs -f nginx
Copy after login

How to solve nginx startup failure


A bunch of errors were reported, and I didn’t know when the log was logged. After solving it, I guessed it was because The reason why the configuration file is empty is because the event module was not found

So first look at the container information of nginx

docker inspect nginx
Copy after login

How to solve nginx startup failure


Find the mounting information , you can look at the configuration file and find that there is no configuration file in /usr/nginx/conf. You should have found the problem at this time; but the operation and maintenance students created an empty nginx.conf when querying the problem, and I did not open the configuration file.

Later, at the boss’s reminder, I opened the configuration file and found that it was empty, and then modified the configuration file.

First I found a default nginx.conf configuration

#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;
Copy after login

Then docker start nginx and find that it can be started

Next add the correct jira configuration

 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;
        }
Copy after login

Enter the container to check whether there is any problem with the configuration file

docker exec -it 容器id /bin/bash
Copy after login

nginx path search find / -name nginx

./nginx/sbin/nginx -t
Copy after login

Detection found one missing}

:set nu
Copy after login

Find the specific line and then fix it

ctrl +D  // 退出容器
Copy after login

Start nginx

docker restart nginx
Copy after login

The above is the detailed content of How to solve nginx startup failure. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!