Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pulse00/5420524 to your computer and use it in GitHub Desktop.
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/
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