gpt4 book ai didi

Nginx - 使用/子文件夹重定向反向代理 Ghost 博客

转载 作者:行者123 更新时间:2023-12-04 18:27:17 25 4
gpt4 key购买 nike

我有一个符合以下规则的工作 nginx 实例。但是我很难将所有请求指向 domain.com/ghost

我尝试将 location/{} block 修改为 location/ghost/{} 但没有成功。我刚从 ghost 应用程序收到 404。有什么建议吗?

server {
listen 80;
server_name domain.com;
root /home//user/ghost/;
index index.php;

# if ($http_host != "domain.com") {
# rewrite ^ http://domain.com$request_uri permanent;
# }

location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:2368;
}

location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)$ {
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
proxy_pass http://127.0.0.1:2368;
}

location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }

location ~ /\.ht {
deny all;
}
}

最佳答案

我正在使用正则表达式 location 指令进行类似的代理设置。这是缩小的配置文件:

worker_processes  1;
pid /path/to/file.pid;
worker_priority 15;

events {
worker_connections 512;
accept_mutex on;
}

http {
server {
error_log /path/to/log/error.log error;
listen 127.0.0.1:9000;
server_name example.com;

location ~* (/ghost) {
expires epoch;
proxy_no_cache 1;
proxy_pass http://localhost:1234;
}

location / {
proxy_pass http://localhost:1234;
}
}
}

关于Nginx - 使用/子文件夹重定向反向代理 Ghost 博客,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20077208/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com