728x90
Rocky Linux 에서 nginx 설치 방법을 기록해 두고자 한다.
root 사용자로 nginx 를 설치하고, nginx.conf 를 수정후 systemctl 로 서비스 등록만 하면 된다.
- nginx 설치
| # dnf install nginx |
- nginx.conf 수정
| # cd /etc/nginx # vi 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 8;
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 2048;
}
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;
upstream tomcat {
server 127.0.0.1:8085;
}
# 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.
include /etc/nginx/conf.d/*.conf;
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 / {
proxy_pass http://tomcat;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
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 20250710/cert.pem;
ssl_certificate_key 20250710/key.pem;
ssl_password_file 20250710/ssl_password;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers PROFILE=SYSTEM;
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 {
}
}
}
: http - upstream 부분은 tomcat 서버(보통 Java Spring 프레임워크를 사용하면 내장 웹서버로 실행되는) 정보를 입력한다.
: ssl 설정을 위해 키 파일들을 ssl_certificate, ssl_certificate_key 에 설정한 위치에 복사해둔다. 해당 파일이 없을 경우 nginx 서비스가 시작이 안된다. 당장 https 가 필요없을 경우, TLS server 부분을 comment 처리한다.
- 서비스 등록 및 시작
| # systemctl enable nginx # systemctl start nginx |
'Engineering > Tomcat' 카테고리의 다른 글
| SSL cipher suite ordering - Linux (2) | 2014.09.17 |
|---|---|
| 인증서의 fingerprint(sha1, sha256) 확인 (0) | 2014.09.03 |
| tomcat keygen 간단 명령어 (1) | 2014.08.22 |