nginx背后的javaweb服务
给定我的rest服务的代码片段:
@POST
@Path("account")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ManagedAsync
public void save(final Account account, @Suspended final AsyncResponse response)
现在,我有了这个nginx配置来将请求传递给它:
location ~ /rest/?(.*)$ {
proxy_pass http://localhost:8080;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
port_in_redirect off;
}
我的问题是:
如果我使用json正文和内容类型application/json发布到/rest/account(nginx端口80),我会得到一个415不支持的媒体类型错误。但是如果我直接发布到端口8080(到ws-app),那么一切都很好——我得到201响应
nginx似乎没有传递正确的内容类型。它的配置中有什么我遗漏的吗
这是nginx。配置文件:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
共 (0) 个答案