我在带有 nginx 的 Ubuntu 14.04 上。我的网站是用 laravel 构建的,它可以像您期望的那样工作:example.com、example.com/page 等都可以工作
我要做的是:example.com 上的每个页面都应该由 laravel 提供服务,除了 example.com/blog。/blog 应该由 Ghost 提供。
网站的位置是:
- /var/www/laravel(/public) 用于主站点
- /var/www/ghost 用于博客
由于本教程的帮助,我设法在子域 (ghost.example.com) 上成功安装了 Ghost:https ://www.digitalocean.com/community/tutorials/how-to-create-a-blog-with -ghost-and-nginx-on-ubuntu-14-04
现在,当我访问 example.com/blog 时,它链接到 example.com
这是我的 nginx 配置文件:
server {
listen 443;
ssl on;
ssl_certificate ...;
ssl_certificate_key ...;
server_name example.com;
include hhvm.conf;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
root /var/www/laravel/public;
index index.html index.htm index.php;
location / {
# URLs to attempt, including pretty ones.
try_files $uri $uri/ /index.php?$query_string;
}
location ^~ /blog {
# this works perfectly
# return 301 http://www.google.com;
# I got this code from the tutorial
proxy_set_header X-Real-IP $remote_addr;
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_pass http://127.0.0.1:2368;
proxy_redirect off;
}
# Remove trailing slash to please routing system.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
}
幽灵配置文件:
production: {
url: 'https://example.com/blog',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
host: '0.0.0.0',
port: '2368'
}
},