Nginx 배치 전후 단 분리 서비스
날아가다
설정 nginx
일반 nginx 프로필 은 etc 디 렉 터 리 에 있 습 니 다.
cd /etc/nginx
sudo vi nginx.conf
  또한 nginx. conf 설정 파일 을 찾 는 방법:
sudo find /etc -name nginx.conf  //  /etc       nginx.conf     
sudo locate nginx.conf  //locate                ,       find    ,           ,                       ,             locate       ,      updatedb    ,    mlocate    
  앞 뒤 분리 단 항목 에 서 는 전단 의 코드 가 정적 파일 로 포 장 됩 니 다.Nginx 를 사용 하 는 목적 은 정적 파일 을 서 비 스 를 실행 시 키 는 것 입 니 다. 백 엔 드 의 인터페이스 도 분리 되 어 있 기 때문에 직접 요청 하면 크로스 도 메 인 문제 가 발생 할 수 있 습 니 다. 이 때 Nginx 퍼 가기 에이전트 백 엔 드 인터페이스 가 필요 합 니 다.
nginx 설정:
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto; #    
error_log /var/log/nginx/error.log; #      
pid /run/nginx.pid; #PID  
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
    worker_connections 1024; #    worker process           
}
http {
    gzip on; #  gzip  
    gzip_min_length 1k; #               
    gzip_buffers    4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 6; #         ,   1-9,       
    gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml; #           
    gzip_vary on;
    #      
    server {
        listen       80;<      Nginx         /span>
        server_name  mark.binlive.cn;
        root /home/spa-project/dist; #               
        index index.html; #  index  
        error_page    404         /index.html; # 404        index.html    history          
        location ^~ /api/{
            proxy_pass http://127.0.0.1:7000;
            proxy_send_timeout 1800;
            proxy_read_timeout 1800;
            proxy_connect_timeout 1800;
            client_max_body_size 2048m;
            proxy_http_version 1.1;  
            proxy_set_header Upgrade $http_upgrade;  
            proxy_set_header Connection "Upgrade"; 
            proxy_set_header  Host              $http_host;   # required for docker client's sake
            proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP
            proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
            proxy_set_header  X-Forwarded-Proto $scheme;
        }
        location ^~ /auth/{
            proxy_pass http://127.0.0.1:7000;
            proxy_send_timeout 1800;
            proxy_read_timeout 1800;
            proxy_connect_timeout 1800;
            client_max_body_size 2048m;
            proxy_http_version 1.1;  
            proxy_set_header Upgrade $http_upgrade;  
            proxy_set_header Connection "Upgrade"; 
            proxy_set_header  Host              $http_host;   # required for docker client's sake
            proxy_set_header  X-Real-IP         $remote_addr; # pass on real client's IP
            proxy_set_header  X-Forwarded-For   $proxy_add_x_forwarded_for;
            proxy_set_header  X-Forwarded-Proto $scheme;
        }
    }    
}
  역할
nginx -t  //  Nginx       
nginx  //               nginx  
nginx -s reload
  질문
nginx - t 를 실행 할 때 다음 과 같은 오류 가 발생 했 습 니 다.
nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed
  구 글 이 해답 을 얻어 usernginx 를user nobody nogroup 로 바 꾸 기;그리고 nginx - t 를 다시 실행 하면 잘못 보고 하지 않 습 니 다.
END
Thanks!
https://segmentfault.com/a/1190000014972747
https://serverfault.com/questions/581145/getpwnamwww-failed-in-etc-nginx-nginx-conf
https://blog.csdn.net/tojohnonly/article/details/70160388
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.