blacklabelops-legacy / nginx

Dockerized Ready-To-Go Nginx Reverse Proxy. Let's encrypt Support!
MIT License
95 stars 41 forks source link

Server Set Headers #2

Closed shaneseaton closed 8 years ago

shaneseaton commented 8 years ago

Hi,

I found your container really useful. The only thing I've found missing is the ability to set headers through the environment variables. Something like:

SERVER[num]PROXY[num]HEADER[num] = ""

$ docker run -d \ -p 80:80 \ --name nginx \ -e "SERVER1REVERSE_PROXY_LOCATION1=/" \ -e "SERVER1REVERSE_PROXY_PASS1=http://www.heise.de" \ -e "SERVER2SERVER_NAME=dummy.example.com" -e "SERVER2REVERSE_PROXY_LOCATION2=/alternate" \ -e "SERVER2REVERSE_PROXY_PASS2=http://www.alternate.de" \ -e "SERVER1PROXY1HEADER1=X-Forwarded-For $proxy_add_x_forwarded_for" \ -e "SERVER1PROXY1HEADER2=X-Script-Name /" \ -e "SERVER1PROXY2HEADER1=X-Forwarded-For $proxy_add_x_forwarded_for" \ -e "SERVER1PROXY2HEADER2=X-Script-Name /alternate" \ blacklabelops/nginx

Thoughts? Would be cool if you could use env variable substitution too.

-e "SERVER1PROXY2HEADER2=X-Script-Name ${SERVER2REVERSE_PROXY_LOCATION2}" 

but that might be asking a bit much :)

Cheers, Shane.

blacklabelops commented 8 years ago

Yes, that's necessary. I like it!

Let's see what I can do!

blacklabelops commented 8 years ago

Implemented, please read Readme for details!

blacklabelops commented 8 years ago

You can control the type of substitution with the quotes around environment variables: