chrome://appcache-internals/
nginx rewrite
reference
http://seanlook.com/2015/05/17/nginx-location-rewrite/
wget http://www.lighttpd.net/download/spawn- fcgi-1.6.3.tar.bz2
#! / bin / sh export PHP_FCGI_MAX_REQUESTS=0 /usr/local/spawn/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u haoning -g haoning -f /usr/local/php5/bin/php-cgi -P /var/run/fastcgi-php.pid
This is running php.
Be sure to set PHP_FCGI_MAX_REQUESTS=0
, otherwise the maximum number of connections is 500.
The nginx echo module is installed for testing
.
./configure --prefix=/usr/local/nginx --with-http_ssl_module --add-module=/opt/echo-nginx-module make make install
Modify the nginx configuration file
nginx.conf
#user nobody; user haoning; worker_processes 8; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid logs/nginx.pid; events { worker_connections 1024; } http { 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; keepalive_timeout 65; #gzip on; server { listen 80; server_name 192.168.8.61; #server_name 192.168.0.110; #charset koi8-r; charset utf-8; #access_log logs/host.access.log main; location / { root /var/www; index index.html index.htm; } location /jslinux-network/ { # rewrite hda(.*).bin http://$SERVER_NAME$REQUEST_URI/../disk-expander.php?index=$1; # rewrite hdb(.*).bin http://$SERVER_NAME$REQUEST_URI/../disk-expander.php?index=$1&hdb=true; # rewrite ^offlinemanifest.appcache$ http://$SERVER_NAME$REQUEST_URI/../offlinemanifest.php; # rewrite ^index.html$ http://$SERVER_NAME$REQUEST_URI/../index.php; # #for rewrite test #rewrite a.html http://$SERVER_NAME$REQUEST_URI/../b.html last; rewrite hda(.*).bin /jslinux-network/disk-expander.php?index=$1; rewrite hdb(.*).bin /jslinux-network/disk-expander.php?index=$1&hdb=true; rewrite offlinemanifest.appcache$ /jslinux-network/offlinemanifest.php; rewrite index.html /jslinux-network/index.php last; rewrite a.html /jslinux-network/b.html last; root /var/www; index index.html index.htm; } location /hello { echo -n $document_uri; } location ~* \.(gif|jpg|jpeg)$ { echo -n "haha"; #rewrite \.(gif|jpg)$ /logo.png; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; set $path_info "/"; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } } #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 html; root /var/www; } fastcgi_param SCRIPT_FILENAME /var/www/$real_script_name; fastcgi_param script_name $real_script_name; fastcgi_param path_info $path_info; include /usr/local/nginx/conf/fastcgi_params; # 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$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$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; #} } # 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; # } #} }
After the modification, the apache
responsible for forwarding can retire
https://github.com/killinux/jslinux-network
Pay attention to some global variables, which can be used directly in the nginx configuration file
$args : #This variable is equal to the parameters in the request line, same as $query_string $content_length : The Content-length field in the request header. $content_type : The Content-Type field in the request header. $document_root : The value specified in the root directive for the current request. $host : The request host header field, otherwise the server name. $http_user_agent : client agent information $http_cookie : client cookie information $limit_rate : This variable can limit the connection rate. $request_method : The action requested by the client, usually GET or POST. $remote_addr : The IP address of the client. $remote_port : The port of the client. $remote_user : The username that has been authenticated by the Auth Basic Module. $request_filename : The file path of the current request, generated by the root or alias directive and the URI request. $scheme : HTTP method (eg http, https). $server_protocol : The protocol used by the request, usually HTTP/1.0 or HTTP/1.1. $server_addr : The server address, which can be determined after a system call. $server_name : Server name. $server_port : The port number where the request arrives at the server. $request_uri : The original URI containing the request parameters, excluding the hostname, eg: "/foo/bar.php?arg=baz". $uri : The current URI without request parameters, $uri does not contain the hostname, such as "/foo/bar.html". $document_uri : Same as $uri.