Created
April 19, 2013 13:55
-
-
Save pulse00/5420524 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 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