Production environment:
Operating System: CentOS 6.8
Web Services software: nginx-1.10.1
task-driven: received leadership instructions, to the size of about 14G college students to publish the series of video online.
Analysis tasks: Considering that this video capacity is large, this format does not support online playback, but also conducive to the school teachers and students to facilitate access to video materials, while at the same time to meet the superior check.
How to resolve: let teachers and students download videos to the local computer to watch the study.
Effect: through the completion of practical tasks to digest 1 months to learn nginx knowledge.
There are two options to choose from:
1. centos+apache: Dynamic business, you can choose Apache, the recommended choice nginx.
2. Centos+nginx: Static business, high concurrency scenario, using Nginx, both static business and dynamic business, will also use Nginx, this task is static business, so choose Nginx.
Operation Steps:
1. compress each video separately on the client and then upload it to the Linux server via WINSCP.
2. installation of nginx service software omitted.
3. mainly for Nginx basic security optimization, optimization of parameters to improve service performance, restrict site source IP Access, error page jump, Site directory and directory permissions optimization, control the number of concurrent connections, control the rate of client requests .
[[email protected] conf]# CA t nginx.conf
User Nginx Nginx; # Change the Default user
worker_processes 2; # because there are 2 CPUs, so the number of 2 processes is configured
Worker_rlimit_nofile 65535; # the maximum number of open files for a process, which should be placed in the Main tab segment
Events {
Use Epoll; # event-handling model optimization
Worker_connections 512; # the number of client connections allowed by a single client process, because the hardware configuration is too low, so the number is relatively small;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
CharSet Utf-8; # fix Web page garbled
server_tokens off; # turn off display service version information
Tcp_nodelay on; # Improve I/O performance
Client_header_timeout 15; # time-out for client request header data
Client_body_timeout 15; # timeout period for client request principal
Send_timeout 25;
Client_max_body_size 8m; # upload file deadline limit
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" "$http _x_forwarded_for";
#access_log Logs/access.log Main;
Sendfile on; # efficient transfer mode for file opening
Tcp_nopush on; # prevent network and disk blocking
Keepalive_timeout 60; # Setting the connection timeout
# include extra/nginx_vhosts.conf;
Limit_conn_zone $binary _remote_addr zone=addr:10m;
Limit_req_zone $binary _remote_addr zone=one:20m rate=1r/s; # control the Nginx rate of client requests
server {
Listen 9090; # with 9090 ports, the default is 80 ports
server_name 117.40.*.*:9090;
Access_log/application/nginx/logs/www.access.log;
Error_log/application/nginx/logs/www.error.log;
Limit_conn addr 10; # limit the number of concurrent connections for a single IP
Limit_req Zone=one burst=30; # Queue of Requests
Location/{
root/application/nginx/html/www;
Error_page 404/404.html; # when a 404 error occurs, it jumps to the 404.html page
error_page 404 http://117.*.*.*; # two ways to use one of the options to solve the actual problem
AutoIndex on; #开启显示目录功能
Autoindex_exact_size off; # Displays the approximate size of the file, in GB
Autoindex_localtime on; # The file time displayed is the server time of the file
Deny 192.168.1.1; # allow only this IP access
Allow 192.168.1.0/24; # allow only this IP segment access
Allow 192.168.0.0/16; # allow only this IP segment access
Allow 117.40.*.*/24; # allow only this IP segment access
Allow 182.99.242.*; # allow only this IP access
Deny all; # except as permitted above, the others are forbidden.
}
}
}
[email protected] html]# chmod 755 www # directory permissions, guaranteed not to suffer Trojan invasion
[email protected] www]# chmod 644 * * # file Permissions
This article is from the "sky9890" blog, make sure to keep this source http://sky9896.blog.51cto.com/2330653/1885696
Nginx releases static business