Mat*_*att 1 nginx https magento
我今天早上醒来发现我一直在自学的新 Nginx 服务器不再为网站提供服务。看起来这是因为 Nginx 不再运行。但是,当我尝试启动它时,出现此错误:
Starting nginx: nginx: [emerg] unknown "https" variable
[FAILED]
Run Code Online (Sandbox Code Playgroud)
现在据我所知,没有任何变化,昨天运行良好,但到目前为止我没有查到任何帮助我找到解决方案的方法。
如果我运行 service nginx restart ,我会得到以下信息:
nginx: [emerg] unknown "https" variable
nginx: configuration file /etc/nginx/nginx.conf test failed
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已经找到了关于此的所有内容,例如这里和其他一些地方: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;
}
Run Code Online (Sandbox Code Playgroud)
它目前正在运行一个测试 Magento 站点,它的 .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
}
}
Run Code Online (Sandbox Code Playgroud)
我的 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;
Run Code Online (Sandbox Code Playgroud)
有没有人看到我遗漏的东西?我需要查看另一个文件吗?
任何建议将不胜感激,谢谢。
将此添加到 http {} 中的 Nginx 配置中。旧版 Nginx 的问题在于未定义变量。这定义了变量。
map $scheme $fastcgi_https {
default off;
https on;
}
Run Code Online (Sandbox Code Playgroud)
没有设置 $_SERVER['HTTPS'] 不会阻止 SSL 正常工作,但会将 Magento 发送到安全页面上的无限重定向循环中。Magento 会检查当前页面是否应该是安全的,然后检查它是否真的安全。如果没有,它会重定向到安全 URL。问题是此检查检查是否存在 $_SERVER['HTTPS']。
归档时间: |
|
查看次数: |
16971 次 |
最近记录: |