728x90
React 샘플 프로젝트 배포를 Apache 로 설정하려다가 포기했다. 이미 환경설정이 PHP로 VirtualHost 설정이 되어 있어서 문제가 되는가 싶어 Apache stop 을 시키고 nginx 설치를 했다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
# 시스템 정보 노출 제한
server_tokens off;
# 디렉토리 검색 방지
autoindex off;
ssl_protocols TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers off;
# Redirect all HTTP traffic to HTTPS for spb.abc.com
server {
listen 80;
server_name spb.abc.com;
return 301 https://spb.abc.com$request_uri;
}
# Reverse Proxy for spb.abc.com with React static files
server {
listen 443 ssl;
server_name spb.abc.com;
ssl_certificate /etc/letsencrypt/live/spb.abc.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/spb.abc.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/spb.abc.com/chain.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
error_log /var/log/nginx/spb-error.log;
access_log /var/log/nginx/spb-access.log main;
root /home/react/react-auth/build;
index index.html;
location / {
try_files $uri /index.html;
limit_except GET POST {
deny all;
}
}
location /static/ {
root /home/react/react-auth/build;
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
location ~* \.(?:js|css|json|ico|png|jpg|jpeg|svg|woff|woff2|ttf|otf|eot|mp4|webm|ogv|ogg|mp3|wav|webp)$ {
expires max;
access_log off;
add_header Cache-Control "public";
}
}
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy "no-referrer-when-downgrade";
include /etc/nginx/conf.d/*.conf;
}
|
Rocky Linux 9.5 가 TLS 1.3을 지원하기 때문에 1.3버전만 명시했다.
아래 스크립트는 nginx 설치과정부터 설명한 내역이다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
####################################################################
# Apache를 설치한 경우에는 아파치 동작 중지
systemctl stop httpd
####################################################################
# nginx 설치 과정
####################################################################
# 패키지 관리자 업데이트
dnf -y update
# NGINX RPM 패키지 도구(dnf, yum)로 설치하는 방법
dnf -y install yum-utils
# NGINX 공식 저장소를 추가
vi /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
#wq(저장하고 빠져나오기)
# NGINX 최신 버전과 버그 수정을 포함하는 mainline 버전을 사용하려면 다음 명령어를 실행
yum-config-manager --enable nginx-mainline
# 버그 수정만 포함한 안정 버전을 사용하려면 다음 명령어을 실행
yum-config-manager --enable nginx-stable
# NGINX 패키지 설치 ==> NGINX 공식 저장소에서 최신 버전의 NGINX 패키지를 다운로드하고 설치
dnf -y install nginx
# NGINX 버전 확인
nginx -v
####################################################################
# nginx 데몬 실행
####################################################################
systemctl start nginx
systemctl enable nginx
systemctl status nginx
# 환경파일 수정
vi /etc/nginx/nginx.conf
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
# 시스템 정보 노출 제한
server_tokens off;
# 디렉토리 검색 방지
autoindex off;
ssl_protocols TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers off;
# Redirect all HTTP traffic to HTTPS for spb.abc.com
server {
listen 80;
server_name spb.abc.com;
return 301 https://spb.abc.com$request_uri;
}
# Reverse Proxy for spb.abc.com with React static files
server {
listen 443 ssl;
server_name spb.abc.com;
ssl_certificate /etc/letsencrypt/live/spb.abc.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/spb.abc.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/spb.abc.com/chain.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
error_log /var/log/nginx/spb-error.log;
access_log /var/log/nginx/spb-access.log main;
root /home/react/react-auth/build;
index index.html;
location / {
try_files $uri /index.html;
limit_except GET POST {
deny all;
}
}
location /static/ {
root /home/react/react-auth/build;
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
location ~* \.(?:js|css|json|ico|png|jpg|jpeg|svg|woff|woff2|ttf|otf|eot|mp4|webm|ogv|ogg|mp3|wav|webp)$ {
expires max;
access_log off;
add_header Cache-Control "public";
}
}
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy "no-referrer-when-downgrade";
include /etc/nginx/conf.d/*.conf;
}
# 저장하고 나온다.
# 설정 테스트
sudo nginx -t
#설정 반영 및 Nginx 재시작
systemctl restart nginx
#Ownership
chown nginx:nginx -R /home/react/react-auth/build
|
React 빌드 및 nginx 재시작
728x90
'React > React' 카테고리의 다른 글
React Naver Map API 사용 샘플 (2) | 2022.10.25 |
---|---|
React 카카오맵 API 사용 샘플 (0) | 2022.10.24 |
React useMemo & useCallback (0) | 2022.10.24 |
React useRef 사용 예제 (0) | 2022.10.15 |
React useReducer (0) | 2022.10.13 |