>  기사  >  운영 및 유지보수  >  nginx 시작 실패를 해결하는 방법

nginx 시작 실패를 해결하는 방법

王林
王林앞으로
2023-05-26 19:55:383544검색

Operation

우선 nginx는 자체적으로 배포되지 않기 때문에 먼저 시작해야 합니다

docker start nginx

nginx 시작 실패를 해결하는 방법

nginx가 인쇄된 것을 발견했지만 docker ps는 nginx가 여전히 시작되지 않는 것을 발견했습니다

그래서 준비했습니다. 로그를 확인해보세요

docker logs -f nginx

nginx 시작 실패를 해결하는 방법


오류가 많이 나네요. 언제 로그가 기록됐는지 모르겠네요. 해결하고 보니 구성 파일이 비어 있어서 그런 것 같아요.

그래서 마운트 정보를 찾기 위해 먼저 nginx

docker inspect nginx

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가 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 시작 실패를 해결하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 yisu.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제