server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
root /usr/share/nginx/html;
#除了指定 ip,其他 ip 都禁止
allow 10.74.31.15;
deny all;
gzip off;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://127.0.0.1:8888/;
}
#需要在同一域名端口下 使用子目录的形式挂载一个新的服务,可以使用 sub_filter 来实现,此命令可以
#对页面中的文本做替换,比如 /static 目录下的静态资源使其指向新路径 /new_server/static .
location /new_server/ {
proxy_pass http://127.0.0.1:8888/;
sub_filter '/api' '/new_server/api';
sub_filter "/static" '/new_server/static';
sub_filter 'BDP' 'bdp' ;
sub_filter_once off;
sub_filter_types *;
sub_filter_types text/html text/plain text/xml text/css text/js image/webp;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
nginx 使用
最新推荐文章于 2024-07-11 14:15:33 发布