nginx添加请求头字段、apache添加响应头字段 nginx添加请求头字段、apache添加响应头字段

nginx添加请求头字段、apache添加响应头字段

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/baidu_36649389/article/details/81318691

nginx添加请求头字段:

server{

……

proxy_set_header MyHeader “test”;

……

}

apache添加响应头字段(windows):

修改配置文件httpd.conf

将下面这句话前面的“#”去掉。
LoadModule headers_module modules/mod_headers.so

在配置文件的最后添加:

Header append MyHeader “test”
即可。

扫描二维码关注公众号,回复: 3106111 查看本文章

apache添加响应头字段(linux):

1)、首先要安装mod_headers.c模块。

进入lamp源代码安装目录 modules/metadata :

  • [root@localhost ~]# cd /lamp/httpd-2.2.20/modules/metadata

执行 ls | grep 命令,我们发现有几个文件:

  • mod_headers.c
  • mod_headers.dep
  • mod_headers.dsp
  • mod_headers.exp
  • mod_headers.mak

我们需要的是 mod_headers.c

然后用apxs工具添加模块(注意apxs的路径是在apache安装目录下):

  • [root@localhost metadata]# /usr/local/apache2/bin/apxs -i -a -c mod_headers.c

稍等片刻,安装完毕后重启httpd服务。

  • service httpd restart

2)、自定义网页header信息

修改Apache配置文件httpd.conf(注意httpd.conf在apache安装目录的conf文件夹下):

  • [root@localhost]# vim /usr/local/apache2/conf/httpd.conf
  • <IFModule mod_headers.c>
  • Header add MyHeader “hello”
  • </IFModule>

添加完后立即测试:

  • [root@localhost]# curl -I 192.168.0.10/test.php
  • HTTP/1.1 200 OK
  • Date: Sat, 19 Apr 2014 02:45:13 GMT
  • Server: Apache/2.2.16 (Unix) PHP/5.3.27
  • X-Powered-By: PHP/5.3.27
  • MyHeader: hello //自定义的header
  • Content-Type: text/html

完!!

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/baidu_36649389/article/details/81318691

nginx添加请求头字段:

server{

……

proxy_set_header MyHeader “test”;

……

}

apache添加响应头字段(windows):

修改配置文件httpd.conf

将下面这句话前面的“#”去掉。
LoadModule headers_module modules/mod_headers.so

在配置文件的最后添加:

Header append MyHeader “test”
即可。

apache添加响应头字段(linux):

1)、首先要安装mod_headers.c模块。

进入lamp源代码安装目录 modules/metadata :

  • [root@localhost ~]# cd /lamp/httpd-2.2.20/modules/metadata

执行 ls | grep 命令,我们发现有几个文件:

  • mod_headers.c
  • mod_headers.dep
  • mod_headers.dsp
  • mod_headers.exp
  • mod_headers.mak

我们需要的是 mod_headers.c

然后用apxs工具添加模块(注意apxs的路径是在apache安装目录下):

  • [root@localhost metadata]# /usr/local/apache2/bin/apxs -i -a -c mod_headers.c

稍等片刻,安装完毕后重启httpd服务。

  • service httpd restart

2)、自定义网页header信息

修改Apache配置文件httpd.conf(注意httpd.conf在apache安装目录的conf文件夹下):

  • [root@localhost]# vim /usr/local/apache2/conf/httpd.conf
  • <IFModule mod_headers.c>
  • Header add MyHeader “hello”
  • </IFModule>

添加完后立即测试:

  • [root@localhost]# curl -I 192.168.0.10/test.php
  • HTTP/1.1 200 OK
  • Date: Sat, 19 Apr 2014 02:45:13 GMT
  • Server: Apache/2.2.16 (Unix) PHP/5.3.27
  • X-Powered-By: PHP/5.3.27
  • MyHeader: hello //自定义的header
  • Content-Type: text/html

完!!

猜你喜欢

转载自blog.csdn.net/weixin_41909810/article/details/82556237