@yanglt7
2018-10-21T15:56:25.000000Z
字数 4111
阅读 1210
Web集群实战
[root@ylt001 conf]# curl -I 192.168.2.137HTTP/1.1 301 Moved PermanentlyServer: nginx/1.14.0 # <-- 这里暴露了 Web 版本号及软件名称Date: Sat, 29 Sep 2018 05:14:06 GMTContent-Type: text/htmlContent-Length: 185Connection: keep-aliveLocation: http://www.yangyangyang.org/

[root@ylt001 conf]# cat nginx.confworker_processes 1;error_log logs/error.log;events {worker_connections 1024;}http {...server_tokens off;...}# 参数作用:激活或禁止 Nginx 的版本信息显示在报错信息和 Server 的响应首部位置中
[root@ylt001 conf]# /application/nginx/sbin/nginx -s reload[root@ylt001 conf]# curl -I 192.168.2.137HTTP/1.1 301 Moved PermanentlyServer: nginx # <-- 版本号已消失Date: Sat, 29 Sep 2018 05:24:09 GMTContent-Type: text/htmlContent-Length: 178Connection: keep-aliveLocation: http://www.yangyangyang.org/

[root@ylt001 conf]#grep '#user' nginx.conf.default#user nobody;
[root@ylt001 conf]# useradd nginx -s /sbin/nologin -M[root@ylt001 conf]# id nginxuid=1001(nginx) gid=1001(nginx) groups=1001(nginx)
[root@ylt001 conf]# sed -i 's#\#user nginx#user nginx nginx#g' nginx.conf.default[root@ylt001 conf]# grep 'user nginx nginx' nginx.conf.defaultuser nginx nginx;
[root@ylt001 conf]# ps -ef|grep nginx|grep -v greproot 1702 1 0 08:42 ? 00:00:00 nginx: master process /application/nginx/sbin/nginxnginx 67706 1702 0 13:24 ? 00:00:00 nginx: worker process
server {listen 80;server_name yangyangyang.org;location / {root html/www;index index.html index.htm;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires 10y;root html/www;}location ~ .*\.(js|css)?${expires 30d'}access_log logs/access_www.log main gzip buffer=32k flush=5s;}
location ~ ^/(images|javascripts|js|css|flash|media|static)/{expires 360d;}
location ~ .*\.(js|jpg|JPG|jpeg|JPEG|css|bmp|gif|GIF)$ {access_log off;}
chown -R root.root /application/nginx/logs/chmod -R 700 /application/nginx/logs/
location ~ ^/images/.*\.(php|php5|sh|pl|py)${deny all;}location ~ ^/static/.*\.(php|php5|sh|pl|py)${deny all;}location ~* ^/data/ (attachment|avatar)/.*\.(php|php5)${deny all;}
location ~ .*\. (php|php5)?${fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fcgi.conf;}
location ~ ^/(static)/{deny all;}location ~ ^/static/{deny all;}location ~ ^/(static|js)/{deny all;}
location ~ ^/ylt/{allow 202.116.83.77deny all;}location ~ .*\. (php|php5)?${fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi_params;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;}
location /{deny 192.168.1.1;allow 192.168.1.0/24;allow 10.1.1.0/16;deny all;}