Created
June 20, 2019 20:11
-
-
Save tmuth/094e51e17478f3e852b1f0d760379cdf to your computer and use it in GitHub Desktop.
nginx Proxy for Splunk HEC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes auto; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
log_format '$remote_addr - $remote_user [$time_local] ' | |
'"$request" $status $body_bytes_sent ' | |
'"$http_referer" "$http_user_agent" "$gzip_ratio"'; | |
server { | |
# Enable SSL for default HEC port 8088 | |
#listen 8088 ssl; | |
listen 8888; | |
# Configure default Splunk Enterprise certificate. | |
# Private key is included in server.pem so use it in both settings. | |
#ssl_certificate server.pem; | |
#ssl_certificate_key server.pem; | |
location /hec { | |
proxy_pass http://tmuth-mbp17:8088/services/collector; | |
proxy_read_timeout 90; | |
proxy_connect_timeout 90; | |
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; | |
# wrap the event body for splunk | |
proxy_set_body "{\"event\":$request_body}"; | |
# Add the Splunk token into the Authorization header | |
proxy_set_header Authorization "Splunk 15F2903F-4851-4AD2-B4A3-320A65D4C2C1"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment