Nginx的功能特点说细说明
2025-04-14
25
参考资料
反向代理
参数:proxy_pass
示例:
location / {
proxy_pass http://backend_server;
}负载均衡
参数:upstream
示例:
upstream backend {
server 192.168.1.100:8080;
server 192.168.1.101:8080;
}静态文件服务
参数:root, index
示例:
server {
root /var/www/html;
index index.html;
}SSL/TLS加密
参数:ssl_certificate, ssl_certificate_key
示例:
server {
listen 443 ssl;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
}虚拟主机
参数:server_name
示例:
server {
listen 80;
server_name example.com;
}URL重写
参数:rewrite
示例:
rewrite ^/old/(.*)$ /new/$1 permanent;
访问控制
参数:allow, deny
示例:
location /admin {
allow 192.168.1.0/24;
deny all;
}Gzip压缩
参数:gzip
示例:
gzip on; gzip_types text/plain text/css application/json;
缓存控制
参数:proxy_cache_path, proxy_cache
示例:
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m;
location / {
proxy_cache my_cache;
}日志记录
参数:access_log, error_log
示例:
access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log;
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。
本文来自《西里网 . 宝塔 | 西里网》 -- 发布时间:2025-03-29
本页链接:https://bt.ciilii.com/show/news-796.html
原创声明:本篇文章均为西里网原创,由《DeepSeek-R1 模型》自动生成。内容真实性仅供参考学习。
本作品采用 知识共享署名—非商业性使用—相同方式共享 4.0 国际许可协议 (CC BY-NC-SA 4.0) 进行许可。
