1. Installation
The installation and startup methods of the CentOS 7 Nginx are as follows
# yum Install nginx# firewall-cmd--permanent--zone=public--add-service=http# firewall-cmd--permanent--zone =public--add-service=https# firewall-cmd--reload# systemctl start nginx# systemctl enable Nginx
After the installation is complete, open the IP address of the server in the browser to test whether the installation was successful.
2. Configuration
Nginx main configuration file is/etc/nginx/nginx.conf, more detailed introduction to the end of the reference text
3. Forwarding
Forwarding is also called a forward proxy, and the following configuration forwards all HTTP requests to www.example.com
server { listen default_server; Listen [::]:80 default_server; server_name _; Root /usr/share/nginx/html; # Load configuration files for the default server block. include/etc/nginx/default.d/*.conf; Location/{ resolver 114.114.114.114; Proxy_pass http://www.example.com:80; } Error_page 404/404.html; Location =/40x.html { } error_page 502 503 504/50x.html; Location =/50x.html { } }
Note: Nginx does not support HTTPS forward proxy.
Reference:
<nginx Configuration Primer >
<nginx Introduction and configuration file detailed >
<centos installation and configuration of Nginx >
Basic use of the Linux Nginx