我一直在尝试在同一个Digital Ocean Droplet上托管我的网站(Node应用程序)和我的Ghost博客。我已经设置了Nginx,以便将'/'请求发送到我的网站正在服务的端口8080,并且'/ blog'的请求被发送到2368,Ghost的默认端口号。
问题是Ghost安装似乎无法在其目录中找到assets文件夹。基本HTML内容显示,但没有样式。我已经尝试将root配置为指向Ghost所在的子目录无效。
这是我遇到的一个错误(404s):
获取http://MYURL/assets/css/screen.css?v=59384a3875 MYURL / 126 404(未找到)
Picture: HTML content appears, but no styling
Nginx配置:
server {
listen 80;
server_name MYURL;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /blog {
rewrite ^/blog(.*) /$1 break;
proxy_pass http://localhost:2368;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Ghost Production Config:
var path = require('path'),
config;
config = {
// ### Production
// When running Ghost in the wild, use the production environment.
// Configure your URL and mail settings here
production: {
url: 'http://MYURL',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
host: '127.0.0.1',
port: '2368'
}
},
非常感谢任何帮助。
答案 0 :(得分:3)
您正在使用未代理的/assets/css/screen.css?v=59384a3875
我的意思是您尚未添加location /assets
但仍在使用。您需要为location
添加另一个assets
指令,就像您的nginx配置
server {
listen 80;
server_name MYURL;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /assets {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /blog {
rewrite ^/blog(.*) /$1 break;
proxy_pass http://localhost:2368;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
您可能希望从所有静态内容中删除/
,例如使用assets/css/screen.css?v=59384a3875
而不是/assets/css/screen.css?v=59384a3875
,但您可以从html,js,css等处删除。