Nginx的未知“https”variables

我今天早上醒来发现,我一直在教自己的一个新的Nginx服务器不再提供服务的网站。 看起来这是因为Nginx不再运行。 当我尝试启动但是,我得到这个错误:

Starting nginx: nginx: [emerg] unknown "https" variable [FAILED] 

现在据我所知,没有任何改变,昨天运行良好,但迄今为止,我没有看到什么帮助我find了解决办法。

如果我运行服务nginx重新启动,我得到如下:

 nginx: [emerg] unknown "https" variable nginx: configuration file /etc/nginx/nginx.conf test failed 

到目前为止,我已经能够find关于这方面的一切,比如这里和其他一些地方: http : //www.howtoforge.com/forums/showthread.php? t = 60733表示注释掉fastcgi_params,但是,我没有这些线路摆在首位。

我也试着对https引用进行注释,只是为了看看会发生什么,但似乎没有任何区别。

我的Nginx.conf文件是:

 user nginx; worker_processes 1; #error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; error_log /var/log/nginx/error.log info; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; autoindex off; map $scheme $fastcgi_https { ## Detect when HTTPS is used default off; https on; } #keepalive_timeout 0; keepalive_timeout 65; gzip on; gzip_comp_level 2; gzip_proxied any; #gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; # Load config files from the /etc/nginx/conf.d directory # The default server is in conf.d/default.conf include /etc/nginx/conf.d/*.conf; } 

目前它正在运行一个testingMagento站点,它的.conf文件如下所示:

  server { listen 80; server_name freshtrifle.com; rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www } server { listen 80; ## SSL directives might go here server_name www.freshtrifle.com *.freshtrifle.com; ## Domain is here twice so server_name_in_redirect will favour the www root /var/www/freshtrifle.com; location / { index index.html index.php; ## Allow a static html file to be shown first try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler expires 30d; ## Assume all files are cachable } ## These locations would be hidden by .htaccess normally location ^~ /app/ { deny all; } location ^~ /includes/ { deny all; } location ^~ /lib/ { deny all; } location ^~ /media/downloadable/ { deny all; } location ^~ /pkginfo/ { deny all; } location ^~ /report/config.xml { deny all; } location ^~ /var/ { deny all; } location /var/export/ { ## Allow admins only to view export folder auth_basic "Restricted"; ## Message shown in login window auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword autoindex on; } location /. { ## Disable .htaccess and other hidden files return 404; } location @handler { ## Magento uses a common front handler rewrite / /index.php; } location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler rewrite ^(.*.php)/ $1 last; } location ~ .php$ { ## Execute PHP scripts if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss expires off; ## Do not cache dynamic content fastcgi_pass 127.0.0.1:9000; fastcgi_param HTTPS $fastcgi_https; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores fastcgi_param MAGE_RUN_TYPE store; include fastcgi_params; ## See /etc/nginx/fastcgi_params } } 

我的fastcgi_params文件如下所示:

 fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; 

有没有人看到我失踪的东西? 还有另外一个文件,我需要看看?

任何意见将不胜感激,谢谢。

在http {}中添加这个到你的Nginxconfiguration。 较旧的Nginx版本的问题是该variables未定义。 这定义了variables。

 map $scheme $fastcgi_https { default off; https on; } 

没有设置$ _SERVER ['HTTPS']将不能保持SSL的正常工作,但会将Magento发送到安全页面上的无限redirect循环。 Magento会检查当前页面是否安全,然后检查它是否确实安全。 如果不是,则redirect到安全URL。 问题是这个检查检查是否存在$ _SERVER ['HTTPS']。

更新Nginx到版本1.2.7,到目前为止,这似乎已经修复了它。 没有一个.conf文件已经改变了,所以我假设里面有一些不兼容的东西。 我不知道究竟是什么或为什么不立刻停止工作,但在这个阶段似乎所有的更新后,它应该运行。

如果Google把我的情况带到这里,就像我一样:

我在我们的ubuntu dev服务器上运行Nginx 1.2.7,刚刚经历了这个。 我从Magento wiki获得了conf文件并作了一些更改:

»删除顶部server部分摆脱www。 重写
»将magento.com更改为magento
»在第51行附近(如上面的链接所示),我用违规variables注释掉了这一行。
# fastcgi_param HTTPS $fastcgi_https;
»执行sudo service nginx restart

而现在我的Magento 1.7.0.2安装可以前进。 如果你在这里,你得到了Magento安装404错误,你需要上面的configuration文件。

当时间到了的时候勾选跳过基本URLvalidation的框。