SSL Linux 적용버전
 PM2 사용법
설치
npm install pm2 -g
무중단 서비스 시작
(*) 코어 2개씩 돌릴 때 인자값을 2로 설정한다. CPU 개수가 많으면 많을수록 조정해서 줄 수 있다.
pm2 start authServer.js -i 0 2 --watch
pm2 start app.js -i 0 2 --watch
pm2 프로세스 확인
pm2 monitor
CentOS 환경에서의 CPU 갯수 확인
grep -c processor /proc/cpuinfo
====================================================================
Nginx 
엔진x의 에러 유무 확인
sudo nginx -t
엔진x 리버스 프록시 설정 : 다른 도메인:80포트로 각각 실제 포트가 다른 내부 서비스로 지정해서 사용가능
설정 내용
- 도메인1 (인증서비스) : auth-minokuma.duckdns.org => localhost:4000
- 도메인2 (앱 서비스) : minokuma.duckdns.org => localhost:3000
sudo vi /etc/nginx/nginx.conf
-----------------------------------------------------------------------------------------------
# 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;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
    worker_connections 1024;
}
http {
    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  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
server{
listen 80;
server_name auth-minokuma.duckdns.org;
    include /etc/nginx/conf.d/*.conf;
        location / {
           proxy_pass      http://localhost:4000;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection 'upgrade';
           proxy_set_header Host $host;
           proxy_cache_bypass $http_upgrade;
           }
        }
server{
listen 80;
server_name minokuma.duckdns.org;
location / {
        proxy_pass      http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        }
}
#    server {
#        listen       80 default_server;
#        listen       [::]:80 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }
# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }
}
--------------------------------------------------------------------------------------------------------
엔진 X
설정이 끝나면, 아래 실행/정지/재시작 으로 사용
sudo service nginx start
sudo service nginx stop
sudo service nginx restart
==============================================================
무료 SSL 관련
https://jootc.com/p/201901062488 참조...
SSL 성공완료된 Nginx 환경파일 : /etc/nginx/nginx.conf
---------------------------------------------------------------------------------------------------------
# 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;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
    worker_connections 1024;
}
http {
    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  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
# newly added
#location /.well-known {
#       root /var/www/certbot-webroot/;
#}
# newly added
server{
listen 80;
server_name auth-minokuma.duckdns.org;
    include /etc/nginx/conf.d/*.conf;
        location / {
           proxy_pass      http://localhost:4000;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection 'upgrade';
           proxy_set_header Host $host;
           proxy_cache_bypass $http_upgrade;
           }
        }
server{
#listen 80;
#listen 443;
#server_name minokuma.duckdns.org;
server_name minokuma.tk;
location / {
        proxy_pass      http://minokuma.tk:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        }
        listen 443 ssl;
        ssl_certificate "/etc/letsencrypt/live/minokuma.tk/fullchain.pem";
        ssl_certificate_key "/etc/letsencrypt/live/minokuma.tk/privkey.pem";
}
#    server {
#        listen       80 default_server;
#        listen       [::]:80 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }
# Settings for a TLS enabled server.
#
    server {
        listen       443 ssl http2;
        listen       [::]:443 ssl http2;
        server_name  minokuma.tk www.minokuma.tk;
        root         /usr/share/nginx/html;
        include /etc/nginx/conf.d/*.conf;
        ssl_certificate "/etc/letsencrypt/live/minokuma.tk/fullchain.pem";
        ssl_certificate_key "/etc/letsencrypt/live/minokuma.tk/privkey.pem";
#        include /etc/letsencrypt/options-ssl-nginx.conf;
#       ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
#
        location / {
        }
#
        error_page 404 /404.html;
            location = /40x.html {
        }
#
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}
------------------------------------------------------------------------------------------------------------
참고 : https://akal.co.kr/?p=1781
댓글
댓글 쓰기