Map*_*ple 12 nginx directory reverse-proxy
我想在我的 VPS 上为我的 Heroku 应用程序(http://lovemaple.heroku.com)设置一个反向代理所以如果我访问mysite.com/blog
我可以在http://lovemaple.heroku.com 中获取内容
我按照Apache wiki上的说明进行操作。
location /couchdb {
rewrite /couchdb/(.*) /$1 break;
proxy_pass http://localhost:5984;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Run Code Online (Sandbox Code Playgroud)
我改变了它以适应我的情况:
location /blog {
rewrite /blog/(.*) /$1 break;
proxy_pass http://lovemaple.heroku.com;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Run Code Online (Sandbox Code Playgroud)
当我访问时mysite.com/blog
,页面显示出来,但无法获取 js/css 文件(404)。
他们的链接变为mysite.com/style.css
但不是mysite.com/blog/style.css
。
出了什么问题,我该如何解决?
您需要修复 HTML 中的引用,nginx 不负责为您执行此操作。您可以将它们设置为与它们所在的目录无关:
<link rel="stylesheet" type="text/css" href="style.css">
Run Code Online (Sandbox Code Playgroud)
(而不是"/style.css"
)
归档时间: |
|
查看次数: |
25252 次 |
最近记录: |