Nginx function Explanation:
1. Reverse proxy: Requires multiple programs to share the 80 port when the use of reverse proxy, Nginx is a reverse proxy implementation.
2. Static resource management: generally use Nginx to do reverse proxy, static resources should be put to nginx management.
3. Load balancing: slightly.
Nginx principle:
Nginx essentially creates a server that listens on port 80 through a configuration file and then redirects the request to the specified port via that server.
Nginx for HTTPS access:
The principle is the same as above, use the configuration file to create an HTTPS server, and then redirect the request through that server to the specified port.
Why use Nginx to manage static resources?
1. Reduced redirection time
2.nginx provides high-performance, static resource management
To install Nginx on Ubuntu:
Reference official website: https://www.nginx.com/resources/wiki/start/topics/tutorials/install/
Start Nginx:/usr/sbin/nginx
Restart Nginx:/usr/sbin/nginx-s Reload
Quit Nginx:/usr/sbin/nginx-s quit
Add a Nginx configuration, you can imitate/etc/nginx/conf.d/veily.conf, add a server.
Example:
server {
Listen 80;
server_name xcx.veilytech.com;
Rewrite ^/(. *) $ https://xcx.xxxx.com:443/$1 permanent;
}
server {
Listen 443 SSL;
SSL_CERTIFICATE/ETC/LETSENCRYPT/LIVE/XCX.XXXX.COM/FULLCHAIN.PEM;
SSL_CERTIFICATE_KEY/ETC/LETSENCRYPT/LIVE/XCX.XXXX.COM/PRIVKEY.PEM;
Keepalive_timeout 70;
server_name xcx.xxxx.com;
#禁止在header中出现服务器版本 to prevent hackers from exploiting version exploits
Server_tokens off;
# ......
Fastcgi_param HTTPS on;
Fastcgi_param Http_scheme HTTPS;
Location/{
Proxy_pass http://127.0.0.1:8093/;
}
}
Nginx basic usage and HTTPS configuration