0%

Nginx

Nginx

Install

Download Nginx

Start Nginx

  1. Double-click to start nginx.exe, and the command box flashes past
  2. Enter the command nginx.exe or start nginx

Reload Nginx

1
nginx -s reload

Stop Nginx

1
2
3
4
5
# Out of service
nginx -s quit

# Forced shutdown of service
nginx -s stop

Domain name binding

1
2
3
server {
server_name www.itblood.com; #Domain name
}

Forwarding service

1
2
3
4
5
6
location / {
proxy_pass http://127.0.0.1:8080; # Forwarding address
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Setup Nginx starts from startup

Convert the Nginx to the system service

  1. Download the ‘Windows Service Wrapper’

  2. Place the program in the directory of Nginx and rename ‘nginx-service.exe’.

  3. Create configuration file ‘nginx-service.xml’

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <service>
    <id>nginx</id>
    <name>nginx</name>
    <description>nginx</description>
    <logpath>D:\xxx\nginx-x.x.x</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <executable>D:\xxx\nginx-x.x.x\nginx.exe</executable>
    <stopexecutable>D:\xxx\nginx-x.x.x\nginx.exe -s stop</stopexecutable>
    </service>
  4. Execute ‘nginx-service.exe install’ in the CMD in the curent directory

    Structure Tree

  5. The Service item is set to start

-------------The end of this article, thanks for reading-------------