You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I copied the nginx.tmpl from the nginx proxy into /tmp/templates and edited it.
Since I am doing a simple test without proxying anything I assume I can add headers to the "server {" - so that when I hit the server it will return the headers and the 503.
The stanza looks like this:
server {
server_name _; # This is just an invalid value which will never trigger on a real hostname.
listen 80;
{{ if $enable_ipv6 }}
listen [::]:80;
{{ end }}
access_log /var/log/nginx/access.log vhost;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
return 503;
}
If I docker exec -it id /bin/bash in the running nginx container I can see the /etc/nginx/conf.d/default.conf has the "add_header's" in it.
...
proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port;
# Mitigate httpoxy attack (see README for details)
proxy_set_header Proxy "";
server {
server_name _; # This is just an invalid value which will never trigger on a real hostname.
listen 80;
access_log /var/log/nginx/access.log vhost;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
return 503;
}
If I point chrome at http://localhost and open the tools, the response headers only contain:
HTTP/1.1 503 Service Temporarily Unavailable
Server: nginx/1.15.12
Date: Fri, 10 May 2019 20:45:58 GMT
Content-Type: text/html
Content-Length: 600
Connection: keep-alive
Any ideas what I am doing wrong?
The text was updated successfully, but these errors were encountered:
Adds the specified field to a response header provided that the response code equals 200, 201
(1.3.10), 204, 206, 301, 302, 303, 304, 307 (1.1.16, 1.0.13), or 308 (1.13.0). Parameter value can contain >variables.
I have been trying to add CORS headers to the nginx proxy. I have a simple test that does not seem to work. Any ideas?
I used the example in the docker-gen docs and did this:
I copied the nginx.tmpl from the nginx proxy into /tmp/templates and edited it.
Since I am doing a simple test without proxying anything I assume I can add headers to the "server {" - so that when I hit the server it will return the headers and the 503.
The stanza looks like this:
If I docker exec -it id /bin/bash in the running nginx container I can see the /etc/nginx/conf.d/default.conf has the "add_header's" in it.
If I point chrome at http://localhost and open the tools, the response headers only contain:
Any ideas what I am doing wrong?
The text was updated successfully, but these errors were encountered: