mirror of
https://github.com/demostf/proxy
synced 2026-06-03 12:04:07 +02:00
json access logs
This commit is contained in:
parent
fea8c88976
commit
3d42ac0100
4 changed files with 100 additions and 32 deletions
|
|
@ -1,6 +1,6 @@
|
|||
FROM jonasal/nginx-certbot
|
||||
COPY nginx.conf /
|
||||
COPY entrypoint.sh /
|
||||
COPY entrypoint.sh site.conf /
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY 413.html /var/www
|
||||
|
||||
CMD ["/bin/bash", "/entrypoint.sh"]
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
sed -e "s/\${SOURCE}/$HOST/" -e "s/\${TARGET}/$TARGET/" nginx.conf > /etc/nginx/conf.d/$HOST.conf
|
||||
sed -e "s/\${SOURCE}/api.$HOST/" -e "s/\${TARGET}/$TARGET/" nginx.conf > /etc/nginx/conf.d/api.$HOST.conf
|
||||
sed -e "s/\${SOURCE}/static.$HOST/" -e "s/\${TARGET}/$TARGET/" nginx.conf > /etc/nginx/conf.d/static.$HOST.conf
|
||||
sed -e "s/\${SOURCE}/sync.$HOST/" -e "s/\${TARGET}/$TARGET/" nginx.conf > /etc/nginx/conf.d/sync.$HOST.conf
|
||||
sed -e "s/\${SOURCE}/$HOST/" -e "s/\${TARGET}/$TARGET/" site.conf > /etc/nginx/conf.d/$HOST.conf
|
||||
sed -e "s/\${SOURCE}/api.$HOST/" -e "s/\${TARGET}/$TARGET/" site.conf > /etc/nginx/conf.d/api.$HOST.conf
|
||||
sed -e "s/\${SOURCE}/static.$HOST/" -e "s/\${TARGET}/$TARGET/" site.conf > /etc/nginx/conf.d/static.$HOST.conf
|
||||
sed -e "s/\${SOURCE}/sync.$HOST/" -e "s/\${TARGET}/$TARGET/" site.conf > /etc/nginx/conf.d/sync.$HOST.conf
|
||||
|
||||
/scripts/start_nginx_certbot.sh
|
||||
|
|
|
|||
89
nginx.conf
89
nginx.conf
|
|
@ -1,27 +1,70 @@
|
|||
server {
|
||||
listen 443 ssl;
|
||||
server_name ${SOURCE};
|
||||
ssl_certificate /etc/letsencrypt/live/${SOURCE}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/${SOURCE}/privkey.pem;
|
||||
user nginx;
|
||||
worker_processes auto;
|
||||
|
||||
root /var/www;
|
||||
error_log /var/log/nginx/error.log notice;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
error_page 413 /413.html;
|
||||
|
||||
access_log /logs/${SOURCE}.log;
|
||||
|
||||
location / {
|
||||
proxy_pass http://${TARGET};
|
||||
proxy_set_header Host $host;
|
||||
proxy_connect_timeout 6000;
|
||||
proxy_send_timeout 12000;
|
||||
proxy_read_timeout 12000;
|
||||
send_timeout 12000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
client_max_body_size 150M;
|
||||
add_header Permissions-Policy interest-cohort=();
|
||||
}
|
||||
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"';
|
||||
log_format json_analytics escape=json '{'
|
||||
'"msec": "$msec", ' # request unixtime in seconds with a milliseconds resolution
|
||||
'"connection": "$connection", ' # connection serial number
|
||||
'"connection_requests": "$connection_requests", ' # number of requests made in connection
|
||||
'"pid": "$pid", ' # process pid
|
||||
'"request_id": "$request_id", ' # the unique request id
|
||||
'"request_length": "$request_length", ' # request length (including headers and body)
|
||||
'"remote_addr": "$remote_addr", ' # client IP
|
||||
'"remote_user": "$remote_user", ' # client HTTP username
|
||||
'"remote_port": "$remote_port", ' # client port
|
||||
'"time_local": "$time_local", '
|
||||
'"time_iso8601": "$time_iso8601", ' # local time in the ISO 8601 standard format
|
||||
'"request": "$request", ' # full path no arguments if the request
|
||||
'"request_uri": "$request_uri", ' # full path and arguments if the request
|
||||
'"args": "$args", ' # args
|
||||
'"status": "$status", ' # response status code
|
||||
'"body_bytes_sent": "$body_bytes_sent", ' # the number of body bytes exclude headers sent to a client
|
||||
'"bytes_sent": "$bytes_sent", ' # the number of bytes sent to a client
|
||||
'"http_referer": "$http_referer", ' # HTTP referer
|
||||
'"http_user_agent": "$http_user_agent", ' # user agent
|
||||
'"http_x_forwarded_for": "$http_x_forwarded_for", ' # http_x_forwarded_for
|
||||
'"http_host": "$http_host", ' # the request Host: header
|
||||
'"server_name": "$server_name", ' # the name of the vhost serving the request
|
||||
'"request_time": "$request_time", ' # request processing time in seconds with msec resolution
|
||||
'"upstream": "$upstream_addr", ' # upstream backend server for proxied requests
|
||||
'"upstream_connect_time": "$upstream_connect_time", ' # upstream handshake time incl. TLS
|
||||
'"upstream_header_time": "$upstream_header_time", ' # time spent receiving upstream headers
|
||||
'"upstream_response_time": "$upstream_response_time", ' # time spend receiving upstream body
|
||||
'"upstream_response_length": "$upstream_response_length", ' # upstream response length
|
||||
'"upstream_cache_status": "$upstream_cache_status", ' # cache HIT/MISS where applicable
|
||||
'"ssl_protocol": "$ssl_protocol", ' # TLS protocol
|
||||
'"ssl_cipher": "$ssl_cipher", ' # TLS cipher
|
||||
'"scheme": "$scheme", ' # http or https
|
||||
'"request_method": "$request_method", ' # request method
|
||||
'"server_protocol": "$server_protocol", ' # request protocol, like HTTP/1.1 or HTTP/2.0
|
||||
'"pipe": "$pipe", ' # "p" if request was pipelined, "." otherwise
|
||||
'"gzip_ratio": "$gzip_ratio", '
|
||||
'"http_cf_ray": "$http_cf_ray"'
|
||||
'}';
|
||||
|
||||
access_log /logs/access.log json_analytics;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
#gzip on;
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
|
|
|
|||
25
site.conf
Normal file
25
site.conf
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
server {
|
||||
listen 443 ssl;
|
||||
server_name ${SOURCE};
|
||||
ssl_certificate /etc/letsencrypt/live/${SOURCE}/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/${SOURCE}/privkey.pem;
|
||||
|
||||
root /var/www;
|
||||
|
||||
error_page 413 /413.html;
|
||||
|
||||
location / {
|
||||
proxy_pass http://${TARGET};
|
||||
proxy_set_header Host $host;
|
||||
proxy_connect_timeout 6000;
|
||||
proxy_send_timeout 12000;
|
||||
proxy_read_timeout 12000;
|
||||
send_timeout 12000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
client_max_body_size 150M;
|
||||
add_header Permissions-Policy interest-cohort=();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue