1, the installation dependencies
-Y-devel the install PCRE yum zlib devel OpenSSL-devel-GCC GCC C ++ the make- // PCRE, optionally compiler installation OpenSSL
2. Create an application user
useradd -M -s /sbin/nologin nginx
3, install nginx
#tar xf nginx-1.14.0.tar.gz -C /usr/local/src/ #cd /usr/local/src/nginx-1.14.0/ #./configure \ --prefix=/usr/local/nginx \ --user=nginx \ --group=nginx \ --with-http_stub_status_module \ --with-http_ssl_module \ --without-http_rewrite_module \ --with-http_gzip_static_module \ --with-pcre=/home/ap/appuser/web_server/Package/pcre-8.41 \ --with-openssl=/home/ap/appuser/web_server/Package/openssl-1.0.2h \ Notes: --without-http_rewrite_module // override the default module open --with-http_gzip_static_module // open gzip static module configured to transmit pre-compressed file --with-http_ssl_module // used to support HTTPS
4, nginx start, stop,
# / usr / local / nginx / sbin / nginx -c /usr/local/nginx/conf/nginx.conf // specified configuration file to start # / usr / local / nginx / sbin / nginx -s reload // GR # kill -HUP nginx main process ID (CAT /usr/local/nginx/logs/nginx.pid) // GR # / usr / local / nginx / sbin / nginx -s sTOP // Quick stop # / usr / local / nginx / sbin / nginx -s quit // not a new request is received, requesting a connection is completed in the other stop (this method of production is recommended) # / usr / local / nginx / sbin / nginx -t // verify whether the profile nginx correct
5, nginx proxy
server { listen 8080; server_name localhost; location / { root html; index index.html index.htm; } location /web { prox_pass http://127.0.0.1:8080/web; } location /www { prox_pass http://127.0.0.1:8080/web; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }
6, nginx load balancing
upstream java_server { server 192.168.3.11:8080; server 192.168.3.12:8080; } server { listen 8080; server_name localhost; location / { root html; index index.html index.htm; proxy_pass http://java_server; } }
7, nginx certificate configuration
{Server
the listen SSL 443;
server_name localhost;
ssl_certificate SSL / server.cer; // public key certificate (note certification path, the certificate is in my nginx / conf / ssl / under)
ssl_certificate_key SSL / server.key-; // private certificate
ssl_session_cache Shared: the SSL: 10m;
ssl_session_timeout 10m;
ssl_ciphers to HIGH: aNULL: the MD5;!!
ssl_prefer_server_ciphers ON;
LOCATION / {
the root HTML;
index index.html index.htm;
}
}