There is the following code in the website html:
<link rel="stylesheet" href="/static/css/bootstrap.min.css" />
<link rel="stylesheet" href="/static/css/bootstrap-theme.min.css" />
<link rel="stylesheet" href="/static/css/jquery.treegrid.css" />
<link rel="stylesheet" href="/static/css/browseraudit.css" />
The problem now is that the browser cannot read these files
Use go as the server and nginx as the reverse proxy
The html files are placed in the /home/user/project/ directory
static and other folders Also placed in this directory
/home/user/project/ is the project root directory
nginx has made the following configuration
location /static/ {
alias /home/user/project/static/;
}
But it doesn’t feel like it’s working
How can I make the browser correctly find the specified file without modifying the original code of the web page?
拿一个beego的nginx配置文件给你参考,大概原理是除了指明URL里带有的css,js,fonts,img字符的nginx接管,如果文件不存在都转发到后端请求,相当于GO开启的web服务器