Forked from pulse00/nginx reverse proxy with dynamic jolokia backend secured by http basic auth
Created
July 31, 2018 14:12
-
-
Save smowtion/fd6a616eb49c312a538d936bf41afb50 to your computer and use it in GitHub Desktop.
Setup nginx as a reverse proxy for jolokia including http basic auth. You might consider - Restrict the backend URL to your jolokia domains
- Restrict the `Allow-Origin` Access-Control header to your domain Example Request: http://yourNginxProxy.com?uri=your.dynamic.jolokia.domain/jolokia/
This file contains hidden or 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
server { | |
listen 80; | |
server_name localhost; | |
access_log /path/to/jolokia.access.log; | |
location / { | |
if ($request_method = OPTIONS ) { | |
add_header Access-Control-Allow-Origin "*"; # <--- customize this | |
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; | |
add_header Access-Control-Allow-Credentials "true"; | |
add_header Access-Control-Allow-Headers 'Authorization,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; | |
add_header Content-Length 0; | |
add_header Content-Type text/plain; | |
return 200; | |
} | |
proxy_pass http://$arg_uri; | |
proxy_hide_header Access-Control-Allow-Origin; | |
add_header Access-Control-Allow-Origin "*"; # <--- customize this | |
auth_basic "Restricted"; | |
auth_basic_user_file htpasswd; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment