├── Makefile ├── README.rst ├── add-on ├── conf │ └── nginx.conf ├── sites-available │ ├── load-balancer.conf │ └── ssl-reverse-proxy.conf └── ssl │ ├── cert.crt │ └── key.key ├── build └── nginx-service.exe ├── deps └── .gitignore ├── src ├── nginx.ico └── nginx.nsi └── tmp └── .gitignore /Makefile: -------------------------------------------------------------------------------- 1 | NGINX_VERSION=1.6.0 2 | NSSM_VERSION=2.22 3 | 4 | NGINX_LINK=http://nginx.org/download/nginx-$(NGINX_VERSION).zip 5 | NGINX_PKG=nginx-$(NGINX_VERSION) 6 | 7 | NSSM_LINK=http://nssm.cc/download/nssm-$(NSSM_VERSION).zip 8 | NSSM_PKG=nssm-$(NSSM_VERSION) 9 | 10 | BIN= build/nginx-service.exe 11 | 12 | .PHONY: clean all $(BIN) 13 | 14 | $(BIN): deps/$(NGINX_PKG)/* deps/$(NSSM_PKG)/* 15 | cp -r deps/$(NGINX_PKG)/* tmp/ 16 | cp deps/$(NSSM_PKG)/win32/nssm.exe tmp/nssm.exe 17 | cp -r src/* tmp/ 18 | mv tmp/conf/nginx.conf tmp/conf/nginx.conf.orig 19 | cp -r add-on/* tmp/ 20 | cd tmp && makensis nginx.nsi 21 | mv tmp/nginx-service.exe build/nginx-service.exe 22 | 23 | deps/$(NGINX_PKG)/*: deps/$(NGINX_PKG).zip 24 | rm -rf deps/$(NGINX_PKG)/ 25 | unzip deps/$(NGINX_PKG).zip -d deps/ 26 | 27 | deps/$(NSSM_PKG)/*: deps/$(NSSM_PKG).zip 28 | rm -rf deps/$(NSSM_PKG)/ 29 | unzip deps/$(NSSM_PKG).zip -d deps/ 30 | 31 | deps/$(NGINX_PKG).zip: 32 | cd deps && wget $(NGINX_LINK) 33 | 34 | deps/$(NSSM_PKG).zip: 35 | cd deps && wget $(NSSM_LINK) 36 | 37 | clean: 38 | rm -rf deps/* 39 | rm -rf build/* 40 | rm -rf tmp/* 41 | 42 | all: clean $(BIN) 43 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | Nginx for Windows 2 | ================= 3 | 4 | Nginx for Windows is an installer that set up a Nginx instance 5 | running as a service under Microsoft Windows platforms. 6 | The Nginx version will be downloaded in compilation time from Nginx's official site - http://nginx.org/ 7 | To achieve service behaviour it uses the "Non Sucking Service Manager" - http://nssm.cc/ 8 | 9 | Usage 10 | ----- 11 | 12 | In order to build this script, you must have NSIS installed. Under Debian/Ubuntu: 13 | 14 | :: 15 | 16 | $ apt-get install nsis 17 | 18 | Afterwards, just build the NSIS script: 19 | 20 | :: 21 | 22 | $ make 23 | 24 | A binary called ``nginx-service.exe`` will be created inside the "build" folder and can be installed on 25 | any Windows 32&64 bits by just double clicking on it. 26 | 27 | 28 | 29 | New versions 30 | ------------ 31 | 32 | In order to use newer versions of Nginx or NSSM you have to edit the variables inside the makefile choosing the apropiate version number: 33 | 34 | :: 35 | 36 | NGINX_VERSION=X.Y.Z 37 | NSSM_VERSION=2.16 38 | 39 | 40 | Examples 41 | -------- 42 | 43 | The installer will create a folder called ``sites-available`` just like in debian. Inside there are two examples of Nginx sites. You should copy one of them to the sites-enabled folder and restart the service or reload configuration with: 44 | 45 | :: 46 | 47 | C:\Program Files (x86)\Nginx> nginx.exe -s reload -------------------------------------------------------------------------------- /add-on/conf/nginx.conf: -------------------------------------------------------------------------------- 1 | worker_processes 1; 2 | daemon off; 3 | 4 | events { 5 | worker_connections 1024; 6 | } 7 | 8 | http { 9 | include mime.types; 10 | default_type application/octet-stream; 11 | 12 | sendfile on; 13 | 14 | keepalive_timeout 65; 15 | 16 | gzip on; 17 | include ../sites-enabled/*; 18 | } 19 | -------------------------------------------------------------------------------- /add-on/sites-available/load-balancer.conf: -------------------------------------------------------------------------------- 1 | upstream lb { 2 | server :80; 3 | } 4 | 5 | server { 6 | listen 80; 7 | server_name ""; 8 | 9 | location / { 10 | proxy_pass http://lb; 11 | } 12 | } -------------------------------------------------------------------------------- /add-on/sites-available/ssl-reverse-proxy.conf: -------------------------------------------------------------------------------- 1 | server { 2 | client_max_body_size 10240M; 3 | listen 443; 4 | server_name ""; 5 | 6 | ssl on; 7 | ssl_certificate ../ssl/cert.crt; 8 | ssl_certificate_key ../ssl/key.key; 9 | 10 | ssl_session_timeout 5m; 11 | 12 | ssl_protocols SSLv2 SSLv3 TLSv1; 13 | ssl_ciphers HIGH:!aNULL:!MD5; 14 | ssl_prefer_server_ciphers on; 15 | 16 | location / { 17 | proxy_pass http://127.0.0.1/; 18 | proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; 19 | proxy_redirect off; 20 | proxy_buffering off; 21 | proxy_set_header X-Real-IP $remote_addr; 22 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 23 | } 24 | } -------------------------------------------------------------------------------- /add-on/ssl/cert.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICETCCAXoCCQDbE8G3npxnxzANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJB 3 | VTETMBEGA1UECAwKU29tZS1TdGF0ZTEXMBUGA1UECgwOSW52R2F0ZSBTLlIuTC4x 4 | EDAOBgNVBAMMB2ludmdhdGUwHhcNMTIxMDIyMTQyNzM0WhcNMjIxMDIwMTQyNzM0 5 | WjBNMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEXMBUGA1UECgwO 6 | SW52R2F0ZSBTLlIuTC4xEDAOBgNVBAMMB2ludmdhdGUwgZ8wDQYJKoZIhvcNAQEB 7 | BQADgY0AMIGJAoGBALeqYbogAD+Lh9++8dY/sA5WWG4nvQl7oVn8SvWnu6qKKncN 8 | MvkGs0z+sm5cw9q5Ht/GK9/+g2GE6ZRwHXFY+7k9UAQYpoZxKP99eTXi/l3akrhw 9 | 5OohLh/uoc6XTqamW85nKxcuRu35pHmKwdJiU7ZrMvN61Fy1PVktTifKa1JTAgMB 10 | AAEwDQYJKoZIhvcNAQEFBQADgYEAmcymMWf680CupPgcbEfOgDp15LPQPCRcDp9M 11 | 74m9AqTy835H+x38MjJMmYaPdA7Kuw43KJkEuFeun+M29TNQOcRRUQ1RiW3MA2EU 12 | zAgPbE/MIhcCJSssz8pO/6baOHEJfiNExcVfeUEBie4IygdPHl07W+4ZZATxpuvh 13 | b7+67jU= 14 | -----END CERTIFICATE----- 15 | -------------------------------------------------------------------------------- /add-on/ssl/key.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIICXQIBAAKBgQC3qmG6IAA/i4ffvvHWP7AOVlhuJ70Je6FZ/Er1p7uqiip3DTL5 3 | BrNM/rJuXMPauR7fxivf/oNhhOmUcB1xWPu5PVAEGKaGcSj/fXk14v5d2pK4cOTq 4 | IS4f7qHOl06mplvOZysXLkbt+aR5isHSYlO2azLzetRctT1ZLU4nymtSUwIDAQAB 5 | AoGAZU8wdPBt8p9OpZa340xiGqZ6RNjapz5wtCg8WODa3ak031KCiWauxIvBdKrq 6 | xd1TMHAph3bmlYYxKdXmB73jq0y6gde1bVf9+U5ILCRyAHS7YU8Rj1rNT0Xl68Qt 7 | E4jsuMBEd+gDY99zJfTM1kSarlP+iW2yuPJipEltxqR63xECQQDiiOnxtN9osZ3U 8 | onaukTh4AJ4nJNTy3sesi1QkL94vI2vaCwx/Ven2htfJe0wVEhuTEi9KL1GlxBw4 9 | EhM8sQ0XAkEAz44FN6XF0Feljl8bdaWbveVwT+75YD6lU2ak+yqDIwSmKNAL9GN/ 10 | aQbnc9bwdYBa/eGIH0ePu8k9x2bwCf/CJQJBAIPS+phOEcfBvD+1fuzc0wh6C45p 11 | z4W5gGZ2+bLJLDkwGp3a2h3rZ+eu1jmIB2EnlWZDKcO4v4GAGo/CbPFfcmcCQQCf 12 | dS8Q960oSY4J+YuxMRCcLh/BaYnxpW+CycNKq/if+Lxncp8cnSyP1hwP5TxMKda+ 13 | Yn0f+uy0iwGJps4YAIR5AkBHGBGy4tTGO/Ixy+ppVrxNV/ThR2iptrllqb2AsDo9 14 | jtOBTHp4qyu0pr55ANPMKhOVL00UHZQ4mWGRzv7ZwfjI 15 | -----END RSA PRIVATE KEY----- 16 | -------------------------------------------------------------------------------- /build/nginx-service.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InvGate/winginx/b1aec0832fcfafd4d91395ae63053c79f976238d/build/nginx-service.exe -------------------------------------------------------------------------------- /deps/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /src/nginx.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InvGate/winginx/b1aec0832fcfafd4d91395ae63053c79f976238d/src/nginx.ico -------------------------------------------------------------------------------- /src/nginx.nsi: -------------------------------------------------------------------------------- 1 | ; Script generated by the HM NIS Edit Script Wizard. 2 | 3 | ; HM NIS Edit Wizard helper defines 4 | !define PRODUCT_NAME "Nginx" 5 | !define PRODUCT_VERSION "1.6.0" 6 | !define PRODUCT_PUBLISHER "InvGate S.R.L." 7 | !define PRODUCT_WEB_SITE "http://www.invgate.com" 8 | !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\nginx-service.exe" 9 | !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" 10 | !define PRODUCT_UNINST_ROOT_KEY "HKLM" 11 | 12 | Name "${PRODUCT_NAME}" ; ${PRODUCT_VERSION}" 13 | OutFile "nginx-service.exe" 14 | LoadLanguageFile "${NSISDIR}\Contrib\Language files\English.nlf" 15 | LoadLanguageFile "${NSISDIR}\Contrib\Language files\Spanish.nlf" 16 | InstallDir "$PROGRAMFILES\Nginx" 17 | Icon "nginx.ico" 18 | UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\nsis1-uninstall.ico" 19 | InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" 20 | DirText "Setup will install $(^Name) in the following folder.$\r$\n$\r$\nTo install in a different folder, click Browse and select another folder." 21 | ShowInstDetails show 22 | ShowUnInstDetails show 23 | 24 | Function .onInit 25 | FunctionEnd 26 | 27 | Section "Nginx" SEC01 28 | SetOutPath "$INSTDIR" 29 | SetOverwrite try 30 | File "nssm.exe" 31 | File "nginx.exe" 32 | File /r contrib 33 | File /r conf 34 | File /r ssl 35 | File /r docs 36 | File /r html 37 | File /r "sites-available" 38 | CreateDirectory $INSTDIR\logs 39 | CreateDirectory $INSTDIR\temp 40 | CreateDirectory $INSTDIR\sites-enabled 41 | SectionEnd 42 | 43 | Section -Post 44 | ExecWait '$INSTDIR\nssm.exe install Nginx "$INSTDIR\nginx.exe"' 45 | ExecWait '"sc.exe" start nginx' 46 | WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\nginx" \ 47 | "Description" "Nginx HTTP and reverse proxy server" 48 | WriteUninstaller "$INSTDIR\uninst.exe" 49 | WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\nssm.exe" 50 | WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" 51 | WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" 52 | WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\nginx.exe" 53 | WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" 54 | WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" 55 | WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" 56 | SectionEnd 57 | 58 | 59 | Function un.onUninstSuccess 60 | HideWindow 61 | MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." 62 | FunctionEnd 63 | 64 | Function un.onInit 65 | MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 66 | Abort 67 | FunctionEnd 68 | 69 | Section Uninstall 70 | ExecWait '"sc.exe" stop nginx' 71 | ExecWait "$INSTDIR\nssm.exe remove nginx confirm" 72 | RMDir /r "$INSTDIR\conf" 73 | RMDir /r "$INSTDIR\contrib" 74 | RMDir /r "$INSTDIR\html" 75 | RMDir /r "$INSTDIR\docs" 76 | RMDir /r "$INSTDIR\temp" 77 | Delete $INSTDIR\nginx.exe 78 | Delete $INSTDIR\nssm.exe 79 | 80 | DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" 81 | DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" 82 | SetAutoClose true 83 | SectionEnd 84 | -------------------------------------------------------------------------------- /tmp/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | --------------------------------------------------------------------------------