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. 层次节点——NODE节点

    1.html <!DOCTYPE html> <html> <head lang="en"> <meta charset="UT ...

  2. python Tkinter 全屏显示

    #! /usr/bin/env python # -*- coding: utf-8 -*- import Tkinter as tk class FullScreenApp(object): def ...

  3. 三角形(hd1249)

    三角形 Problem Description 用N个三角形最多可以把平面分成几个区域?   Input 输入数据的第一行是一个正整数T(1<=T<=10000),表示测试数据的数量.然后 ...

  4. 多个项目使用NET Core

    .NET Core系列 :3 .使用多个项目   通过前面的两篇文章,我们已经知道如何创建新的项目,如何生成并运行我们的应用程序,也知道(大致) project.json 文件中的内容是什么意思.但大 ...

  5. 微软云基础架构Hyper-scale Datacenter

    每天醒来,可能很多人的习惯都是打开手机,看看微信,刷刷朋友圈,或者看看新闻,去咖啡店,打开电脑搜索一些关键字,观看视频,电视剧--可是你有没有想过你每一次键盘的敲击,每一次微信的语音的发送,数据会流向 ...

  6. 能上QQ无法打开网页

    能上QQ无法上网电脑故障解决方法 Winsock协议配置故障解决方法 第1步 :单击开始菜单中的运行,并在打开的运行窗口中键入“cmd”并回车确定,打死命令提示符窗口. 第2步 :在打开的命令提示符窗 ...

  7. iOS10隐私设置及相应问题

    iOS10新添加了10个隐私设置: NSBluetoothPeripheralUsageDescription="App需要您的同意,才能访问蓝牙"; NSCalendarsUsa ...

  8. Memcached安装卸载

    Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提供动态.数据库驱动网站的速度.Memcached ...

  9. linux下Java环境的配置

    linux下Java环境的配置 现在用linux的朋友越来越多了,前几天就有两个朋友问我linux下怎么配置java环境,我想还有很多朋友想了解学习这方面的东西,就写一个完全一点的linux java ...

  10. beforefieldinit释义(2)

    首先来看一段代码: using System; namespace BeforeFieldInit { internal class Foo { Foo(){ Console.WriteLine(&q ...