只允许本机访问
一般用于设置内部服务器1
2
3
4
5
6
7
8
9
10
11
12
13server {
listen 8888;
server_name localhost;
root /www/vux/vux/my;
location / {
allow 127.0.0.1;
deny all;
try_files $uri $uri/ /index.php?$query_string;
autoindex on;
index index.html index.htm index.php;
include /etc/nginx/conf.d/php-fpm;
}
}
域名(端口)转发
一般用于前后端完全分离的设计1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20server {
listen 80;
server_name douniu.kouhuo.site;
location / {
index index.html index.htm index.php;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080;
}
location /api {
#rewrite ^.+api/?(.*)$ /$1 break;
proxy_redirect off;
proxy_set_header Host $host; #要转发的host
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8888/; #设置要转发的ip(域名)端口
}
}
访问php动态资源(fastcgi)
1 | server { |
配置header头的最大字节数
1 | server{ |
设置超时时间
1 | server{ |