Nginx proxied site can't find static image file on site

您所在的位置:网站首页 挪威人均gdp美元 Nginx proxied site can't find static image file on site

Nginx proxied site can't find static image file on site

2023-01-20 22:01| 来源: 网络整理| 查看: 265

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 5 years ago.

Improve this question

I have a jpg file staying on the media subdirectory of the root path and I use Nginx to serve the file. But when I open the browser it says this in the developer console.

http://localhostmedia/bg.jpg Failed to load resource: A server with the specified hostname could not be found.

I don't know what went wrong. There is no errors in Nginx logs. I am deploying it on my local server not on the internet. Here is my Nginx settings:

upstream ws_upstream { server 127.0.0.1:8888; keepalive 64; } server { listen 0.0.0.0:80 default_server; #listen [::]:80 default_server ipv6only=on; root /usr/local/share/html; index index.html index.htm; server_name ws_server; location / { try_files $uri $uri/ @my_upstream; } location = /index.html { try_files /index.html $uri/ =404; expires 30d; } location ~* \.(gif|jpg|jpeg)$ { root /usr/local/share/html/media; expires 10d; } location @my_upstream { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_pass http://ws_upstream; proxy_read_timeout 240s; } }

What should I change to my file?

UPDATE:

Using curl -i http://localhost will show the source code of the javascript file that my index.html references.

My folder structure for client side in the root path:

/usr/local/share/html -- index.html -- main.js media -- bg.jpg

Here is my index.html file:

My project *{margin:0;padding: 0;} *:focus { outline: none; } html,body,#cas{width:100%;height:100%;overflow: hidden;} .input { border:1px solid #1099bb; border:none; padding-left: 14px; padding-right: 14px; border-radius:18px; -moz-border-radius:18px; -webkit-border-radius:18px; }

Here are some most recent access logs:

2017/08/16 12:58:49 [error] 1883#0: *3 open() "/usr/local/share/html/media/media/bg.jpg" failed (2: No such file or directory), client: ::1, server: ws_server, request: "GET /media/bg.jpg HTTP/1.1", host: "localhost", referrer: "http://localhost/" 2017/08/16 13:12:06 [error] 2111#0: *5 open() "/usr/local/share/htmlindex.html" failed (2: No such file or directory), client: ::1, server: ws_server, request: "GET /__webpack_hmr HTTP/1.1", host: "localhost", referrer: "http://localhost/"


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3