728x90
반응형

1. Nginx 설치

> sudo apt install nginx

# 제거
> sudo apt remove nginx

 

2. Nginx 실행
> sudo service start nginx

# 확인
> sudo service status nginx

 

3. Nginx Version 확인
> sudo dpkg -l nginx
> nginx -v

 

4. Nginx 경로
패키지 설치 기본 폴더는 /etc/nginx/
> sudo find / -name nginx.conf

 

5. Nginx 설정

vi /etc/nginx/conf.d/default.conf

server {
    listen 8080;
    listen [::]:8080;

 

    server_name localhost; # 도메인 주소

 

    root /usr/share/nginx/frontend; # 배포된 프로젝트 경로
    index index.html index.htm;

 

    client_max_body_size 100M;
    location ^~ /api {
        proxy_pass http://127.0.0.1:3100; # backend url
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location ^~ /stream {
        proxy_pass http://127.0.0.1:3100; # backend url

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_cache_bypass $http_upgrade;
}

 

    location / {
        try_files $uri $uri/ /index.html;
    }
}

 

6. Nginx 구동 테스트
> netstat -lntp
# 80번 포트 리스닝 확인

※ netstat이 없다면 apt install net-tools 명령어로 설치

 

7. Nginx log 확인

$ sudo ls /var/log/nginx    //access.log error.log
$ sudo tail -f /var/log/nginx/access.log

 

※ Nginx 윈도우 명령어

 - 시작 명령어 nginx.exe

 - 종료 명령어 nginx.exe –s stop

 - 재시작 명령어 nginx -s reload

728x90
반응형

+ Recent posts