Nginx是一款高性能的Web服务器软件,常用于反向代理、负载均衡、静态资源服务等方面。以下是Nginx常用的配置:配置监听端口:listen 80;
配置网站根目录:root /var/www/html;
配置虚拟主机:server {
listen 80;
server_name example.com;
root /var/www/example.com;
}
配置负载均衡:upstream backend {
server backend1.example.com;
server backend2.example.com;
}
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://backend;
}
}
配置HTTPS:server {
listen 443 ssl;
server_name example.com;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
location / {
proxy_pass http://backend;
}
}