英文:
nginx reverse proxy returns encoded javascript and css
问题
当通过我的nginx代理访问网站时,只有html
加载正确。返回的css
和javascripts
是无意义的。但当我直接访问网站时,javascript加载正确。我不知道为什么会得到这种奇怪的响应。
所有请求都是GET请求
,它们的响应始终是200
。奇怪的是,日志中没有看到任何奇怪的东西。我还尝试关闭GZIP
,但没有解决问题。
这是nginx配置:
server {
listen 80;
server_name wut.*;
location / {
proxy_pass http://10.10.1.60/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
英文:
When accessing the site via my nginx proxy only the html
loads in correctly. The css
and javascripts
that are returned are gibberish. But when I directly access the site the javascript is loaded correctly. I don't Know why I get this weird response.
All the requests are GET-requests
and their responses are always 200
. Weird thing is I don't see anything strange in the logs. I also tried turning of GZIP
but that did not solve it
This is the nginx conf:
server {
listen 80;
server_name wut.*;
location / {
proxy_pass http://10.10.1.60/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
答案1
得分: 0
"我已经打开了gzip,但仍然无法正常工作。原来需要将HTTP版本从1.0升级到1.1
通过在location
块中添加以下行,问题就解决了:proxy_http_version 1.1;
"
英文:
i had gzip turned on and still it did not work. turns out that you need to upgrade the http version from 1.0 --> 1.1
by adding this line in the location
block the problem dissapears: proxy_http_version 1.1;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论