# home/ubuntu/nginx.conf
user nginx;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://{본인_서버_ip}:{포트}; Ex) 192.168.0.21:8080
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}
sudo docker run -d -p 80:80 -v /var/log/nginx:/var/log/nginx -v /home/ubuntu/nginx.conf:/etc/nginx/nginx.conf nginx:latest
https://darkrasid.github.io/docker/container/volume/2017/05/10/docker-volumes.html
-v 옵션으로 도커 내부의 nginx 설정파일, nginx 로그 파일을 host file system과 연결하도록 설정
# /var/awslogs/etc/awslogs.conf
[/var/log/nginx/access.log]
datetime_format = %d/%b/%Y:%H:%M:%S %z
file = /var/log/nginx/access.log
buffer_duration = 5000
log_stream_name = access.log
initial_position = end_of_file
log_group_name = [로그그룹 이름]
[/var/log/nginx/error.log]
datetime_format = %Y/%m/%d %H:%M:%S
file = /var/log/nginx/error.log
buffer_duration = 5000
log_stream_name = error.log
initial_position = end_of_file
log_group_name = [로그그룹 이름]
nohup java -jar ./build/libs/jwp-chess-0.0.1-SNAPSHOT.jar 1> /home/ubuntu/logs/spring/application.log 2>&1 &
# /var/awslogs/etc/awslogs.conf
[/var/log/syslog]
datetime_format = %b %d %H:%M:%S
file = /var/log/syslog
buffer_duration = 5000
log_stream_name = {instance_id}
initial_position = start_of_file
log_group_name = jinho-sys-log
[/var/log/nginx/access.log]
datetime_format = %d/%b/%Y:%H:%M:%S %z
file = /var/log/nginx/access.log
buffer_duration = 5000
log_stream_name = access.log
initial_position = end_of_file
log_group_name = jinho-nginx-access-log
[/var/log/nginx/error.log]
datetime_format = %d/%b/%Y:%H:%M:%S %z
file = /var/log/nginx/error.log
buffer_duration = 5000
log_stream_name = error.log
initial_position = end_of_file
log_group_name = jinho-nginx-error-log
[/var/log/application.log]
datetime_format = %b %d %H:%M:%S
file = /home/ubuntu/logs/spring/application.log
buffer_duration = 5000
log_stream_name = {instance_id}
initial_position = end_of_file
log_group_name = jinho-spring-application-log
인프라 왕자 알리 넘 멋져요