伪静态配置
小于 1 分钟
laravel
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
thinkphp
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
}
}
vue
location / {
try_files $uri $uri/ /index.html;
}
反向代理配置
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://backend_server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
负载均衡配置
http {
# 设置Nginx的全局配置
# 定义上游服务器
upstream backend {
server backend1.example.com weight=3;
server backend2.example.com weight=2;
}
# 配置HTTP服务器
server {
listen 80;
server_name example.com;
# 负载均衡配置
location / {
proxy_pass http://backend;
}
}
}