1. 설치파일 업로드
- 서버에 nginx-1.14.0-1.el7_4.ngx.x86_64.rpm 업로드
2. rpm 설치 & 공통부분 설정
- Root 계정으로 진행
[root@rtls ~]# yum -y localinstall nginx-1.14.0-1.el7_4.ngx.x86_64.rpm
[root@rtls ~]# mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
[root@rtls ~]# vi /etc/nginx/nginx.conf
user flyyunha;
worker_processes auto;
error_log /data/logs/nginx_log/error_log crit;
pid /etc/nginx/nginx.pid;
events {
worker_connections 20000;
}
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 /data/logs/nginx_log/access.log main;
# /var/log/ 경로에 log 안생기게 설정
access_log off;
log_not_found off;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
gzip on;
include /etc/nginx/sites-available/*.conf;
#include /etc/nginx/conf.d/*.conf;
}
2. 특정 포트 연결 설정
[root@rtls ~]# mkdir /etc/nginx/sites-available
[root@rtls ~]# vi /etc/nginx/sites-available/flyyunha.conf
server {
listen 8301; #Listen Port
client_max_body_size 10M;
server_name 192.168.1.1; #해당 서버 IP
charset utf-8;
#charset koi8-r;
# access_log /data/logs/nginx_log/api_log/host.access.log main;
location / {
proxy_pass http://192.168.0.100:8016; #해당 서버 IP 의 Tomcat 포트 8016
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
# location ~ \.do$ {
# proxy_pass http://flyyunha.com;
# }
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
3. log 경로 권한 변경
[root@rtls ~]# chown -R flyyunha:flyyunha /data/contents
[root@rtls ~]# chown -R flyyunha:flyyunha /data/tmp
[root@rtls ~]# chown -R flyyunha:flyyunha /data/logs/nginx_log
4. Tomcat 연결 없이 image 사용시
[root@rtls ~]# vi /etc/nginx/sites-available/contents.conf
server {
listen 80 default_server; #서버에서 사용할 Port
listen [::]:80 default_server; #서버에서 사용할 Port
client_max_body_size 10M;
server_name 192.168.1.100; #해당 서버 IP
charset utf-8;
#charset koi8-r;
#access_log /data/logs/nginx_log/wms_log/host.access.log main;
root /data/contents; #contents 의 root 경로 지정
location ~* \.(?:jpg|jepg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control
"public";
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
'Work > Nginx' 카테고리의 다른 글
Nginx의 로드밸런스 기능 이용 (0) | 2020.04.14 |
---|