1:http协议状态
200 OK
最常见的就是成功响应状态码200了, 这表明该请求被成功地完成,所请求的资源发送回客户端

302 Found
重定向,新的URL会在response 中的Location中返回,浏览器将会自动使用新的URL发出新的Request
例如在IE中输入, http://www.google.com. HTTP服务器会返回302, IE取到Response中Location header的新URL, 又重新发送了一个Request.

304 Not Modified
代表上次的文档已经被缓存了, 还可以继续使用,
例如打开博客园首页, 发现很多Response 的status code 都是304

400 Bad Request  客户端请求与语法错误,不能被服务器所理解
403 Forbidden 服务器收到请求,但是拒绝提供服务
404 Not Found
请求资源不存在(输错了URL)
比如在IE中输入一个错误的URL, http://www.cnblogs.com/tesdf.aspx

500 Internal Server Error 服务器发生了不可预期的错误
503 Server Unavailable 服务器当前不能处理客户端的请求,一段时间后可能恢复正常
502 Bad gateway

2:http服务器控制浏览器缓存
应用场景:某手机web应用。目的:帮助消耗某运营商流量

默认情况下浏览器会对请求内容缓存 首次response 返回200 表示请求成功,当第二次在请求这个页面时候 如图片,css等会根据max生存时间及etag值判断缓存是否过期,如不过期就返回304,使用缓存
这就与消耗流量的目的相违背,为了达到目的需要在服务器发给客户端的http包头上告诉浏览器不要缓存任何内容,每次刷新都新请求

关于http具体的详细过程,cnblogs有一篇不错的文件 http://www.cnblogs.com/TankXiao/archive/2012/11/28/2793365.html 感谢,其中介绍的fiddler2是个不错的工具
然后nginx的配置也有一篇不错的文章http://blog.sina.com.cn/s/blog_5dc960cd0100hxr7.html 感谢

结合这些文章,我在nginx.conf中加了如下配置
location ~ \.(htm|html|gif|jpg|jpeg|png|bmp|ico|css|js)$
               {
                  add_header Cache-Control no-store;
                  add_header Cache-Control private;
               }
重启后,用fiddler2观察,所有请求状态返回码均是200,没有出现304,达到了效果,只是害了用户流量,amen!!!

3:nginx 出现no input file
出现这种情况大部分在用fastcgi解析php,最根本的原因是nginx传给fastcgi的参数(scritpname,script_filename)出错,导致出现弱404(跟传统404稍不同)或者no input file

前提:在nginx.conf中root指令可以定义在server,location段,如果没有没有在任何段定义root,root默认为/path/to/install/html,如/usr/local/nginx/html,nginx在遇到php文件
会交给fastcgi执行,这个转交过程需要nginx告诉fastcgi一些环境运行变量,如cgi version,server software,最重要的是要告诉fastcgi要执行的php路径,SCRIPT_FILENAME,
SCRIPT_NAME,DOCUMENT_URI,DOCUMENT_ROOT,这些变量取得root要么是默认html,要么是写在处理php的location里面的
server {
    index index.php index.html;
    root /www/;
    server_name test.com;
location /a/
{
  root  /test/;
}
location ~ .*\.php?$
 {
        try_files $uri = /50x.html;
         include fastcgi.conf;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
      }

}
此时访问http://test.com/a/index.html,实际访问路径为http://test.com/test/a/index.html 访问正常
如果你访问http://test.com/a/index.php ,不正常,此时就出现了no input file或者是弱404,因为nginx实际访问路径为http://test.com/www/a/index.php
此时www没有a这个目录,要解决此问题可以在
location ~ .*\.php?$
 {
        root /test;
         try_files $uri = /50x.html;
         include fastcgi.conf;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
   }
上述做法是不建议的,因为在处理php的时候一般不可能值处理某个目录下的php,还有一点就是location之间定义的root不能相互继承,所以 php的location
不能使用test 的location root,继承了server级别的root

建议正确配置nginx的方法

在server级别定义root,如果要引用其他目录非root目录,建议使用软连接,软连接被应用目录到root下,如下

1:URL http://test.com:8080/a/index.html 
  I):如果a目录在www目录下,那么上述URL访问html,php完全正常
  II):如果a目录不在www目录下,需要做个软连接 ln -s /path/to/a  /www/a
2:配置文件如下
server 
{
     listen 8080;
     server_name test.com; \\可以定义根据主机头的虚拟主机,主机头
     index index.php index.html;
     root  /www;
     location ~ .*\.php?$
      {
         try_files $uri = /50x.html;   
         
         include fastcgi.conf;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_index index.php;
      } 
}
URL URI区别 见
schema://host[:port#]/path/.../[?query-string][#anchor]

scheme               指定低层使用的协议(例如:http, https, ftp)
host                   HTTP服务器的IP地址或者域名
port#                 HTTP服务器的默认端口是80,这种情况下端口号可以省略。如果使用了别的端口,必须指明,例如 http://www.cnblogs.com:8080/
path                   访问资源的路径
query-string       发送给http服务器的数据
anchor-             锚

3:nginx proxy_pass 的proxy_hearder的一些变量
      proxy_redirect          off;
       proxy_set_header        Host $host;
       proxy_set_header        X-Real-IP $remote_addr;
       proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_pass http://19

http://blog.chinaunix.net/uid-24443760-id-3590539.html

schema://host[:port#]/path/.../[?query-string][#anchor]的更多相关文章

  1. intent-filter 之 data 「scheme, host, port, mimeType, path, pathPrefix, pathPattern」

    之前一直搞不很明白 AndroidManifest.xml 中 activity 标签下的 intent-filter 中 data 标签的属性含义,今天认真看了 Dev Guide,又在网上查询了大 ...

  2. Invalid connection string format, a valid format is: "host:port:sid"

    报错信息: Caused by: java.sql.SQLException: Io 异常: Invalid connection string format, a valid format is:  ...

  3. nodejs笔记三--url处理、Query String;

    URL--该模块包含用以 URL 解析的实用函数. 使用 require('url') 来调用该模块. 一.parse函数的基础用法 parse函数的作用是解析url,返回一个json格式的数组,请看 ...

  4. Reading query string values in JavaScript

    时间 2016-01-23 13:01:14  CrocoDillon’s Blog 原文  http://crocodillon.com/blog/reading-query-string-valu ...

  5. How to get the query string by javascript?

    http://techfunda.com/Tools/XmlToJson http://beautifytools.com/xml-to-json-converter.php https://www. ...

  6. URL query string中文字符问题

    如果URL的query string中包含中文字符,在不做特殊处理的情况下通过 request.getParameter 方法是获取不到正确的信息的,这是由于下面的两个机制造成的 浏览器会自动对URL ...

  7. Are query string keys case sensitive?

    Are query string keys case sensitive? @gbjbaanb's answer is incorrect: The RFCs only specify the all ...

  8. Does not contain a valid host:port authority: Master:8031 (configuration property 'yarn.resourcemanager.resource-tracker.address')

    问题解决: 这个错误是:yarn里面的配置的格式有错误:如: <property> <name>yarn.resourcemanager.address</name> ...

  9. Does not contain a valid host;port authority解决方法

    ERRORorg.apache.hadoop.hdfs.server.namenode.NameNode: java.lang.IllegalArgumentException: Does not c ...

随机推荐

  1. 安装Ubuntu时的硬盘分区方案 转载

    安装Ubuntu时的硬盘分区方案 http://www.cnblogs.com/shenliang123/p/3196743.html 如果你准备在硬盘里只安装Ubuntu一个操作系统的话,建议你采用 ...

  2. 【测试技术】ant中的for循环用法

    有的时候,我们希望ant中也能类似脚本语言一样进行for循环,以实现一些重复性工作.由于ant核心包并未提供此功能,所以需要下载一个扩展包扔到ant的lib目录下去.详细步骤如下: 1.下载核心包:a ...

  3. MFC 遍历FTP服务器目录相关

    CInternetSession* pSession; pSession = new CInternetSession;  //构造新的连接 CFtpConnection* pFtpCon; pFtp ...

  4. system.exit(0) vs system.exit(1)

    2.解析 查看java.lang.System的源代码,我们可以找到System.exit(status)这个方法的说明,代码如下: /** * Terminates the currently ru ...

  5. VMware虚拟机三种网络模式的区别(上篇)

    提到VMware大家就想起了虚拟机技术,虚拟机技术在最近的几年中得到了广泛的发展,一些大型网络服务商都开始采用虚拟机技术,不仅节省了投资成本,更节约了能源的消耗. 我们知道VMware也分几种版本,普 ...

  6. 解决GitHub未配置SSH key提示错误信息

    git push -u origin master Permission denied (publickey). fatal: Could not read from remote repositor ...

  7. sigaction函数解析

    http://blog.chinaunix.net/uid-1877180-id-3011232.html sigaction函数解析  sigaction函数的功能是检查或修改与指定信号相关联的处理 ...

  8. error LNK1104: 无法打开文件“libboost_thread-vc140-mt-gd-1_61.lib”

    error LNK1104: 无法打开文件“libboost_thread-vc140-mt-gd-1_61.lib” 调试->你的项目属性 配置属性->VC++目录 包含目录 D:\bo ...

  9. OC基础8:分类和协议

    "OC基础"这个分类的文章是我在自学Stephen G.Kochan的<Objective-C程序设计第6版>过程中的笔记. 1.关于分类(category): (1) ...

  10. 微信朋友圈分享js代码最新2015年无错版

    最近微信对分享做了进一步规范,导致很多分享都不起作用了,今天跟大家分享,2015年最新修无错的! 以下是主要微信分享页面代码:(其中红色部分主要懒友自己填写自己哈.) <?php require ...