Posted 24 June, 2016
I normally go for Apache as my go-to webserver, lately however I got a liking to Nginx, for no real reasons except for the fact it has a nicer config layout. (a bad reason is a reason non the less) So when I installed Bash for Windows 10, I when and tried Nginx, sadly it didn’t work, and still doesn’t work nicely. I however got it running, this is how : First, install Nginx.
Then I wanted to ignite Nginx, but that did not work, starting Nginx failed cause of port 80 was in use.
2016/06/24 11:37:22 [emerg] 2710#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
Since I am running two systems (Linux and Windows 10) there are plenty of places to look. I started with the location I know best and was most unlikely the problem : Linux. Using netstat -tulpn | grep 80
I verified nothing was running on this freshly installed UbuntuBash. So onto W10, I know Skype, Apache, … uses port 80, but that did not run, so the hunt continued. I finally found -using resmon.exe
– under Listener-port the problem, port 80 was being used by System (PID 4) … not something you can easily kill …
PID 4 (Sytem) was listening on port 80. (no longer seen here)
I dug a bit further and found this useful post. You have to stop some service, this is done using :
net stop http
net stop http in Windows 10 (in dutch)
C:\WINDOWS\system32>net stop http De volgende services zijn afhankelijk van de HTTP Service-service. Als u de HTTP Service-service stopt, worden deze services eveneens gestopt. World Wide Web Publishing-service SSDP Discovery Print Spooler HomeGroup Provider Function Discovery Resource Publication Function Discovery Provider Host Wilt u doorgaan met deze bewerking? (J/N) [N]: j De World Wide Web Publishing-service-service wordt gestopt. De World Wide Web Publishing-service-service is gestopt. De SSDP Discovery-service wordt gestopt. De SSDP Discovery-service is gestopt. De Print Spooler-service wordt gestopt. De Print Spooler-service is gestopt. De HomeGroup Provider-service wordt gestopt. De HomeGroup Provider-service is gestopt. De Function Discovery Resource Publication-service wordt gestopt. De Function Discovery Resource Publication-service is gestopt. De Function Discovery Provider Host-service wordt gestopt. De Function Discovery Provider Host-service is gestopt. De HTTP Service-service is gestopt.
After that I retried nginx to once again be shown an error :
2806#0: ioctl(FIOASYNC) failed while spawning "worker process" (22: Invalid argument)
That was solved using this -still open- bugreport on github. The essence is add the following to /etc/nginx/nginx.conf :
master_process off; #daemon off;
Now to be honest I have got no idea, what any of those parameters do. (note) I tried w/o the daemon parameter and it works as well, so I only use master_process and everything seems to “work”. (different from the solution on github!)
After this, Nginx is running nicely on my BashOnWindows. Pretty nice work, Windows !
// update 28/06
On my second machine I also had to change /etc/nginx/sites-available/default
the following line :
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on;
to
server { listen 80 default_server; #listen [::]:80 default_server ipv6only=on;
This probably cause some ipv6 problem. (this is development only anyway!)
If you enjoyed this article, please consider buying me a Dr Pepper.
Fuel the beast!
Buy me a Dr Pepper
Nice post, thank you!
I’m facing problems with length mismatch, I also wrote here: https://github.com/Microsoft/BashOnWindows/issues/68
@Mocilol advised output_buffers 2 10m; but it makes no difference for me.
My two additional observations:
1. On Windows clients (Chrome) I don’t get this error (strange!), only on Linux (Chrome), Android (Chrome), and iOS (Safari).
2. This error always occurs, if the requested file is > 256k. In this case, only the first 256k is received, nginx stops sending and finally timeouts (based on the send_timeout 2; value – it can be 10, 20, … whatever value), so the browser fails with length mismatch.
I have also tested this with several nginx config files, one of them is the built-in default, and it haven’t worked in any circumstances.
Win10 version: 14393.321 (1607)
nginx version: 1.10.1
Chrome version: 53.x
Do you have any solutions? 🙂
Thank you,
Laci
Hey Laci, sadly I never hit upon this issue … I switched back to a full Linux machine… Goodluck with your search!