共计 2673 个字符,预计需要花费 7 分钟才能阅读完成。
使用宝塔的反代,结果用户无法登录,点了登录后还是显示未登录状态。chevereto v4 有这个问题,v3 没有。
https://v4-docs.chevereto.com/application/stack/web-server.html#nginx
server {
… …
# Disable access to sensitive application files
location ~* (app|content|lib)/.*.(po|php|lock|sql)$ {
return 404;
}
location ~* composer.json|composer.lock|.gitignore$ {
return 404;
}
location ~* /.ht {
return 404;
}
# Image not found replacement
location ~* .(jpe?g|png|gif|webp)$ {
log_not_found off;
error_page 404 /content/images/system/default/404.gif;
}
# CORS header (avoids font rendering issues)
location ~* .(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {
add_header Access-Control-Allow-Origin "*";
}
# PHP front controller
location / {
index index.php;
try_files $uri $uri/ /index.php$is_args$query_string;
}
# Single PHP-entrypoint (disables direct access to .php files)
location ~* .php${
internal;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
}复制代码
zxxx 发表于 2022-12-22 20:34
https://v4-docs.chevereto.com/application/stack/web-server.html#nginx
这个不是反代的配置,是源站的配置。我是希望使用 nginx 反代 chevereto v4 源站上次就给你说了。源站启用 ssl,不要开缓存
toot 发表于 2022-12-22 20:52
上次就给你说了。源站启用 ssl,不要开缓存
源站启用 ssl 了。下面是反代配置,没开启缓存吧。
#PROXY-START/
location /
{
proxy_pass https://a.example.com:port;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
# proxy_hide_header Upgrade;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
proxy_set_header Accept-Encoding "";
sub_filter "a.example.com:port" "https://b.example.com:port";
sub_filter_once off;
set $static_fileYNxzz31H 0;
if ($uri ~* ".(gif|png|jpg|css|js|woff|woff2)$" )
{
set $static_fileYNxzz31H 1;
expires 1m;
}
if ($static_fileYNxzz31H = 0)
{
add_header Cache-Control no-cache;
}
}
#PROXY-END/ 开了缓存“cache”
把下面那一坨全部去除
全部都缓存了,post 就不回源了。当然无法登陆啊
toot 发表于 2022-12-22 21:01
开了缓存“cache”
把下面那一坨全部去除
改成这样了,还是不行:
location / {
proxy_passhttps://xx.xxoo.com:9999;
proxy_redirect https://xx.xxoo.com/ https://$hostserver_port/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}第 4 行 $host 改成 xx.xxoo.com:9999
toot 发表于 2022-12-22 22:30
第 4 行 $host 改成 xx.xxoo.com:9999
改了,还是没效果。奇了怪了。应该是 v4 作者做了写啥限制,这个配置针对 v3 反代没这个问题。
yhsiao 发表于 2022-12-22 22:35
改了,还是没效果。奇了怪了。应该是 v4 作者做了写啥限制,这个配置针对 v3 反代没这个问题。…
我目前也是 v4 反代。没有任何问题。实在配置不来就上宝塔吧简单好用
toot 发表于 2022-12-22 22:41
我目前也是 v4 反代。没有任何问题。实在配置不来就上宝塔吧简单好用
我一开始就是宝塔反代的,有问题。后来就换成自己配置了,还是不行。能分享一下你反代的代码么
yhsiao 发表于 2022-12-22 22:51
我一开始就是宝塔反代的,有问题。后来就换成自己配置了,还是不行。能分享一下你反代的代码么 …
不就那几个选项啊
目标 https://cdn.x.com
发送玉米:cdn.x.com
搞定了,把你的端口去掉再试