使用Nginx反向代理绕过域名备案,代码如下:proxy_pass http://xxx.xxx.xxx.xxx;proxy_set_header X-Real-IP $remote_addr;proxy_set_header User-Agent $http_user_agent;
报错nginx: [error] open() "/run/nginx.pid" failed (2: No such file or directory)
启动:./sbin/nginx -c ./conf/nginx.conf;停止:./sbin/nginx -s stop;开机启动nginx,修改rc.local里面内容。
allow是白名单的意思,deny是白名单的意思,都可作用于http、server、location 里面,我们个别举例。1,location中设置allow。2,http中设置allow,且是直接注入文件,因为要导入的IP太多,比如导入百度云加速IP或者百度蜘蛛IP。
有些资源重要的网站,喜欢收到一些莫名的攻击,接下来教大家如何防范,先给大家看一个被攻击的图。
if ($request_method ~ ^(HEAD)$ ) {};if ($request_method !~* GET|POST) {}
设置这些即可:proxy_set_header X-Real_IP $remote_addr;proxy_set_header Host $host;proxy_set_header X_Forward_For $proxy_add_x_forwarded_for;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;
1,下载nginx-service.exe;2,创建配置文件nginx-service.xml;3,创建nginx-service.exe.config;4,install服务器
网站的访问可以通过配置worker_cpu_affinity参数提升nginx性能,从而提供访问速度。访问人数少的时候不明显,人一旦多了,就会有明细。可以查看电脑任务管理器的CPU性能图。
nginx过滤带有反斜杠的请求:http://127.0.0.1:81/test?id=index\root,四个斜杠"\\\\"代表反斜杠;nginx过滤带有test的请求:http://127.0.0.1:81/test
auth_basic "Please input password";auth_basic_user_file htpasswd;其中auth_basic_user_file的htpasswd值是指定账号密码文件地址,htpassswd文件内容格式:admin:xxxxxxxxx;其admin为账号,xxxxxxxxx为密码,且是MD5加密的密文
proxy_cache_path temp/tmpcache levels=1:2 keys_zone=tmpcache:1024m inactive=7d max_size=2g;
nginx的location配置匹配排除指定目录:location ~* ^/(?![static|h5|web]) { }
nginx的location配置匹配指定多个目录:location ~/(manager|docs|examples|host-manager){}
Nginx实现网站资源压缩是通过ngx_http_gzip_module处理的,对需要做压缩的文件类型做gzip处理,ngx_http_gzip_module是Nginx默认集成的,不需要重新编译,直接开启即可。