---
title: "【电商】nginx问题记录"
author: "dinguangx"
date: "2015-07-22T21:58:56Z"
tags: ["nginx", "电商"]
categories: ["企业架构"]
slug: "nginx"
draft: false
lastmod: "2015-12-30T14:58:02Z"
id: 2229486
url: "https://dinguangx.iteye.com/blog/2229486"
---

**1. 反向代理时，header信息丢失**

自定义的header中带有下划线，nginx在做反向代理时，会认为这样的header是无效的，所以没有进行转发，需要配置underscores\_in\_headers，默认为off,改为on即可.

语法：

```
Syntax:	underscores_in_headers on | off;
Default:	
underscores_in_headers off;
Context: http, server
```

 

参见：http://nginx.org/en/docs/http/ngx\_http\_core\_module.html#underscores\_in\_headers

 

**2. upstream sent invalid chunked response while reading upstream**

出现该问题的原因未知，

解决方法，增加下面的配置:

proxy\_http\_version 1.1;

配置项proxy\_http\_version的默认值为1.0，所以怀疑与1.1中的keepalive特性有关

 

**3. nginx虚拟主机**

配置方式：

```
server {
        listen 80 ;
        server_name jenkins.xxx.cn;
        location / {
           proxy_pass http://127.0.0.1:7081;
        }
}
```

 

 

 如果要配置多个虚拟主机，为保证多个主机可用，如果有一个default的主机(默认已经有了),即:

 listen 80 default;