Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.