由于这个问题,我终于找到了解决图像URL的方法,这个问题稍有不同。
解决方案1
将端口号添加到nginx配置中的Host标头中,如下所示:
location / { proxy_pass http://hello_django; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host:1337; <<------- HERE proxy_redirect off; }解决方案2
将nginx配置中的Host标头更改
http_host如下:
location / { proxy_pass http://hello_django; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; <<------- HERE proxy_redirect off; }无论哪种情况,DURL(图像链接)现在都按以下方式返回图像URL 。
HTTP 200 OKAllow: GET, HEAD, OPTIONSContent-Type: application/jsonVary: Accept{ "count": 1, "next": null, "previous": null, "results": [ { "id": 2, "user": 1, "title": "First post", "slug": "first", "image_url": "http://0.0.0.0:1337/mediafiles/publisher/background.gif", <----HERE "content": "Second post content.", "draft": false, "publish": "2019-05-22", "updated": "2019-05-22T09:41:36.257605Z", "timestamp": "2019-05-22T07:58:01.471534Z" } ]}


