user tanglewang staff; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid /var/log/nginx.pid; events { worker_connections 1024; } http { autoindex on; #另外两个参数最好也加上去: autoindex_exact_size off; #默认为on,显示出文件的确切大小,单位是bytes。 #改为off后,显示出文件的大概大小,单位是kB或者MB或者GB autoindex_localtime on; #默认为off,显示的文件时间为GMT时间。 #改为on后,显示的文件时间为文件的服务器时间 #隐藏nginx版本号 #server_tokens off; #导入类型配置文件 include mime.types; #设定默认类型为二进制流 default_type application/octet-stream; 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; #tcp_nopush on; #keepalive_timeout 0; #设置允许发布内容为20M client_max_body_size 20M; #客户端与服务器连接的超时时间为65秒,超过65秒,服务器关闭连接 keepalive_timeout 600; #是否开启gzip,默认关闭 gzip on; gzip_disable "msie6"; gzip_proxied any; gzip_min_length 4000; gzip_buffers 4 16k; gzip_comp_level 7; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; #指定连接到后端fastCGI的超时时间 fastcgi_connect_timeout 300s; # 向fastCGI请求的超时时间,这个值是指已经完成两次握手后向fastCGI传送的超时时间 fastcgi_send_timeout 300s; #接收fastCGI应答的超时时间,这个值已经完成两次握手后接收fastCGI应答的超时时间 fastcgi_read_timeout 300s; #指定读取fastCGI应答第一部分需要用多大的缓冲区,一般第一部分应答不会超过1k,一般设置为64k fastcgi_buffer_size 128k; # 指定本地需要用多少和多大的缓冲区来缓冲fastCGI的应答 fastcgi_buffers 8 128k;#8 128 # 默认值是fastcgi_buffers的两倍 fastcgi_busy_buffers_size 256k; # 在写入fastcgi_temp_path是用多大的数据块,默认值是fastcgi_buffers两倍 fastcgi_temp_file_write_size 256k; #这个指令指定是否传递4xx和5xx错误信息到客户端,或者允许nginx使用error_page处理错误信息。 fastcgi_intercept_errors off; server { #服务器监听的端口为80 listen 80; #服务器名称为localhost,我们可以通过localhost来访问这个server块的服务 server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; #以root方式设置资源路径,它与alias的不同请见下面的 http模块中文件路径定义 root /Users/tanglewang/htdocs; #location块,它存放在server块当中,location会尝试根据用户请求中的URI来匹配上面的/uri表达式,如果可以匹配,就选择location {}块中的配置来处理用户请求。 location / { #默认访问的页面,从左依次找到右,直到找到这个文件,然后返回结束请求 index index.html index.htm index.php; } #设置错误页面,对应的错误码是404,错误页面是/Users/user/Sites/404.html error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /Users/tanglewang/htdocs; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } ############反向代理测试开始########### server { listen 80; server_name *.pinger.com pinger.com; location / { proxy_pass http://www.baidu.com; } } server { listen 80; server_name *.chungui.com chungui.com; location / { proxy_pass http://www.jd.com; } } server { listen 80; server_name www.test.com; location / { proxy_pass http://www.zhihu.com; } } #server { # listen 7777; # server_name localhost; # index index.html index.htm index.php; # location / { # proxy_pass http://local.vote.com/; # } # location ~ \.php$ { # root /Users/tanglewang/htdocs/nanjingruixiu/vote/public/; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # include fastcgi_params; # } #} ###########反向代理测试结束########### server { listen 8000; server_name localhost; root /Users/tanglewang/htdocs/; location / { index index.html index.htm index.php; } location ~ \.php$ { root /Users/tanglewang/htdocs/; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } server { listen 8001; server_name localhost; root /Users/tanglewang/htdocs/; location / { index index.html index.htm index.php; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} include servers/*; }
本文原地址:https://www.eqiday.cn/141.html
郑重声明内容版权声明:除非注明,否则皆为本站原创文章。如有侵权联系进行删除!