magento - nginx/varnish/magento - 更改端口时出现 500 错误

标签 magento nginx varnish

我已经在 nginx 上安装了 Varnish。我有一些非常大的问题。

我的default.vcl是:

backend default {
.host = "127.0.0.1";
.port = "81";

}

我的网站虚拟服务器是:

server {
listen   80;

root /var/www/site.com.ro/public_html;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name www.site.com.ro;

access_log /var/www/site.com.ro/logs/log.access;
error_log /var/www/site.com.ro/logs/log.error error;

location / {
    index index.php;
    try_files $uri $uri/ @handler;
}

location @handler {
    rewrite /   /index.php;
}

location /blog {
    alias /var/www/site.com.ro/public_html_blog/;
    index index.php index.html index.htm;
    try_files $uri $uri/ /blog/index.php;
}

location ~  ^/blog(.+\.php)$ { ### This location block was the solution
    alias /var/www/site.com.ro/public_html_blog/$1;

    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_read_timeout 300;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location /doc/ {
    alias /usr/share/doc/;
    autoindex on;
    allow 127.0.0.1;
    allow ::1;
    deny all;
}

# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
#   proxy_pass http://127.0.0.1:8080;    
#}

error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/www;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
    if (!-e $request_filename) {
        rewrite / /index.php last;
    }

    try_files $uri =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_read_timeout 300;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#   deny all;
#}

}

服务器{ 听80;

# Make site accessible from http://localhost/
server_name site.com.ro;
rewrite ^(.*) http://www.site.com.ro$1 permanent;

}

Varnish 文件是:

DAEMON_OPTS="-a :80 \
         -T localhost:6082 \
         -f /etc/varnish/default.vcl \
         -S /etc/varnish/secret \
         -s malloc,256m"

当我尝试将网站的监听端口更改为 81 时,出现 500 错误... 谁能帮我?我不知道我做错了什么。

最佳答案

Varnish 配置为监听端口 80,并连接到 localhost:81。 nginx 配置为监听端口 80。您没有提到预期的流程,但我正在疯狂猜测:

client -> varnish:80 -> nginx:81.

你现在发现问题了吗?

提示:

server {
listen   80;

哦,并确保您在尝试不熟悉的设置时使用的测试机(虚拟机或其他设备)中有真正类似的设置。这将使您有时间理解为什么某些东西不起作用,并将为您获得宝贵的经验,这样您就不必弄乱生产站点。

关于magento - nginx/varnish/magento - 更改端口时出现 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21459594/

相关文章:

magento - 在扩展 Mage_Core_Model_Abstract 的几个 Magento 类中,事件/观察者模式被 _beforeSave() 方法重写破坏

php - 504 网关超时 magento

nginx - 使用nginx模拟慢响应时间以进行测试

docker - 在Docker上设置Varnish + Drupal

varnish - 在与网络服务器相同的服务器上设置 Varnish

caching - 您如何测试 Varnish 配置或一般的缓存层

php - Magento V2 API 覆盖产品信息模型 V2(属性未显示)

iphone - 适用于 iOS SDK 的 Magento oauth api

php - Curl 不适用于 Nginx 和本地主机上的 PHP

nginx 容器的 Docker 健康检查