728x90
반응형
우선 기본적으로 Nginx가 설치되어 있다고 가정하고 시작하겠다.
Nginx.conf를 들어가기 위해서
/etc/nginx
위의 해당경로로 들어가주자
conf.d koi-win nginx.conf sites-enabled
fastcgi.conf mime.types proxy_params snippets
fastcgi_params modules-available scgi_params uwsgi_params
koi-utf modules-enabled sites-available win-utf
해당 경로 폴더에 여러가지 파일들이 보인다.
여기서 우리가 건들여 줄 파일은 nginx.conf다.
vi nginx.conf
위의 명령어로 nginx.conf를 설정해주자
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
upstream myapp {
server ${서버1의 IP}:${프론트엔드 Port ex)4173};
server ${서버2의 IP}:${프론트엔드 Port ex)4173};
}
server {
server_name ${로드 밸런싱 해주는 EC2의 IP};
listen 443 ssl; #<-- https
ssl on; #<-- https
ssl_certificate /etc/ssl/certificate.crt; #<-- https
ssl_certificate_key /etc/ssl/private/private.key; #<-- https
location / {
proxy_pass http://myapp;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
위와 같이 설정을 해주자
#<-- https 는 다음에 https 를 설정하면서 conf 파일을 수정한 부분을 알려주겠다.
:wq
저장하고 나가주자
이제 설정했으니 Nginx를 다시 시작해주면 된다.
sudo systemctl restart nginx
문제가 없다면 위의 명령어를 쳤을때 아무 반응이 없을 것이다.
service nginx status
현재 Nginx의 서비스 status를 확인해보자
activated 이면 Nginx의 서버는 문제없이 돌아가고 있을 가능성이 크다.
728x90
반응형
'📁 𝐭𝐨𝐨𝐥&𝐯𝐢𝐫𝐭𝐮𝐚𝐥𝐌𝐚𝐜𝐡𝐢𝐧𝐞 > Nginx' 카테고리의 다른 글
[Nginx] Nginx로 한개의 인스턴스에 연결해주기 (1) | 2023.03.09 |
---|---|
[Nginx] Nginx로 다른 IP에 연결하기 (0) | 2023.03.09 |
[Nginx] Nginx 가 뭘까? (0) | 2023.03.09 |