-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ECR token pushes the line over 4096. Which is unresolvable without rebuilding NGINX #1
Comments
I've come across the same problem on a similar stack, not using the same code/repo so I can't provide you a PR/diff but here's how I worked around it. I hope it helps nginx.conf
renew_token.sh
startup.sh
|
Nice! I totally solved it using a lua block before I saw your reply, but I think either way works.:
# replace the existing token with the new token we retrieved from AWS in the config
# sed -i "s|${ESC}{EXISTING_TOKEN%??}|${ESC}{NEW_TOKEN}|g" $NGINX_CONFIG_DIR/nginx.conf
# create the token file with the new token to fix ecr tokens being too long
echo -n "Basic ${ESC}{NEW_TOKEN}" >> $NGINX_CONFIG_DIR/token
sed 's/^/"/;s/$/"/' $NGINX_CONFIG_DIR/token
server {
listen $PROXY_$PROXY_PORT $PROXY_LISTENER_OPTIONS default_server;
set_by_lua_block ${ESC}auth_headers {
local f = io.open("/usr/local/openresty/nginx/conf/token")
local c = f:read("*all")
f:close()
return c
} and # Add AWS ECR authentication headers
proxy_set_header X-Real-IP ${ESC}remote_addr;
proxy_set_header X-Forwarded-For ${ESC}remote_addr;
proxy_set_header X-Forwarded-User ${ESC}auth_headers;
proxy_set_header Authorization ${ESC}auth_headers;
proxy_set_header X-Forwarded-Proto ${ESC}scheme; I'll probably submit a PR at some point. |
Hi both! Thanks for looking at this; is this some new change to ECR? I've never seen it but admittedly haven't used this project for a few months. Did they change their token format or something? Totally happy to accept a PR for this; I can review or look at fixing myself this weekend as needed too! |
Not as far as I can tell
Side note this also all works on |
I think AWS has increased its token size hence the problem. |
My PR should fix that, it just outputs the token to a file and uses lua to manage the token injection into the headers. |
I'll get to reviewing that ASAP. It looks like this is something recent as the upstream repository also hit it: Lotto24/aws-ecr-http-proxy#31 Edit: oh, ha, I didn't even realise it was you filing that @egeturgay! That other stack is no longer maintained AFAICT, which is why I forked over to here initially. I'll try get this merged and pushed out this weekend! |
I've merged this over, and double checked that it's all still working. I'm going to close this, and I'll push out a new image to Docker Hub as soon as we resolve #3 :) thank you both! |
After further research we discovered all the Token lines were around 4698 characters long, which is way past NGINX limit. Without rebuilding NGINX there is not a way to recover from this error as far as I can tell.
The text was updated successfully, but these errors were encountered: