Sign inSign up

vacant0mens/nginx

By vacant0mens

•Updated about 9 years ago

Windows Server Instance of NGinX

Image
0

2.0K

vacant0mens/nginx repository overview

I searched for a long time to find a version of Nginx for Windows Server, but the only one available was pulled from a Korean website who custom-built it in 64-bit. This one is still 32-bit and it runs in Windows Server Core instead of Nanoserver, but it works and you can add a volume for changing the config file on the fly (if you don't need it, just override the CMD on start.

I originally built it using someone else's dockerfile, but then I needed to be able to change the config file as needed, so I added a few lines and threw one in to create the xconf folder.

Volume: -v [hostfolder]:C:\nginx\xconf

Here's the Dockerfile:

FROM microsoft/windowsservercore:latest
ENV VERSION 1.12.0

SHELL ["powershell", "-command"]
RUN Invoke-WebRequest -Uri https://nginx.org/download/nginx-$ENV:VERSION.zip -OutFile c:\nginx-$ENV:VERSION.zip; \
	Expand-Archive -Path C:\nginx-$ENV:VERSION.zip -DestinationPath C:\ -Force; \
	Remove-Item -Path c:\nginx-$ENV:VERSION.zip -Confirm:$False; \
	Rename-Item -Path nginx-$ENV:VERSION -NewName nginx; \
	New-Item -Type directory C:\nginx\xconf

# Make sure that Docker always uses default DNS servers which hosted by Dockerd.exe
RUN Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters" -Name ServerPriorityTimeLimit -Value 0 -Type DWord; \
	Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters" -Name ScreenDefaultServers -Value 0 -Type DWord; \
	Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters" -Name ScreenUnreachableServers -Value 0 -Type DWord
	
# Shorten DNS cache times
RUN Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name MaxCacheTtl -Value 30 -Type DWord; \
	Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name MaxNegativeCacheTtl -Value 30 -Type DWord

WORKDIR /nginx
CMD .\nginx.exe -c C:\nginx\xconf\nginx.conf

Tag summary

Content type

Image

Digest

Size

5 GB

Last updated

about 9 years ago

docker pull vacant0mens/nginx