I’ve studied load balancing before, I’m currently implementing it on a project (never done anything above small project level, huh), Nginx is fine, but Windows is a bit of a struggle, small traffic and local is not about performance, ease of use is the goal.

Nginx Windows does not provide a way to install Windows Service as a Service. So with this tool, address: https://github.com/xiangyuecn/Nginx-Windows-Service-Manager

What did copy say before

A portal to manage nginx startup, shutdown, restart, reloading configuration, and extension configuration formats is simple enough for lazy people like me.

The following is copied from the README

This tool is used to install and manage Nginx Windows services

Xiangyuecn compiled, learning nginx use, haven’t understand how to configure nginx, the first installation problem solved first, otherwise the server a log off nginx also automatically shut down, first used in 2014-02-20.

Method of use

  1. Copy the five files in the bin directory to the nginx root directory (the same directory as nginx.exe, see Figure 1), with nginx.txt as the optional configuration template file.

  2. Run start.bat to install/uninstall Windows services, run/stop/restart Windows services, update configurations, and reload configurations.

Five files about the bin directory

start.bat

Master script, nginx service management every time run this script can complete easy management; If you need to change the service name and configuration file name, you can change this file, as described below.

rolllog.vbs

Configure template file format processing, date replacement update script

Exe winsw1.9.

Windows installer service, serve system is used to install nginx, download address: http://central.maven.org/maven2/com/sun/winsw/winsw/1.9/ configuration is introduced: https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md.

PsExec.exe

Run start.bat as system user; Bat > start.bat > start.bat > start.bat > start.bat > start.bat > start.bat Start. bat jumps to psexec. exe once, and the user becomes system.

nginx.txt

Configuration template file, support any format repeat content only need to define once, any place reference replacement, greatly simplify the preparation of repeated configuration; This file is not provided without prejudice to use.

On the start. The bat

The configuration part in the file can be adjusted:

  1. The nginx. TXT template file does not have to be placed in the root directory. It can be placed elsewhere by modifying the nginxTxt definition to point to the configuration template file.
  2. The configuration file name is specified using confPath and is conf/nginx.conf by default. If you need to change the file name to another one, change it.
  3. The service name is changed through SVS and the default is Nginx.

After the service is installed and run, Winsw will generate three log files (see Figure 1), which can be deleted. The winSW1.9.xml file cannot be deleted, otherwise it cannot be uninstalled and started.

About nginx. TXT

The contents of this file can be identical to the contents of the nginx configuration file, or you can use the extended syntax to omit scenarios that are not suitable for manual editing.

{y}, {m}, {d}, {h}, {m}, {S}

Current date and time variables such as log paths can be generated dynamically:

logs/access_{y}{m}{d}.log //logs/access_20101229.log
Copy the code

Content supports macro definition and substitution

Definition: DEF(identifier) macro name = macro content (identifier)END, macro name support &, <, >, /, _, -, space, newline, letters, numbers, text combination, macro content can be multiple lines. Use: Write the macro name where you want to replace it.

DEF <StaticExp>=\.(? :png|js|css|ttf|woff|eot|svg|xml|html|jpg|gif|swf)$ END location ~*^/static/.*<StaticExp> {} location ~*<StaticExp> {}Copy the code
DEF <Crt>=ssl_certificate xx.crt;
        ssl_certificate_key xx.key; END
		
...
listen 80;
listen 443 ssl;
<Crt>
...
Copy the code

legend

Document Composition:

Installation services:

Service Management:

Installed services:

The system processes:

Nginx process: