再会!
我有一个使用 MyBB 配置的论坛。Ubuntu 14.04 上一切正常,但我的朋友试图在其上安装 16.04,并首先保存了所有内容(站点配置、letsencrypt 文件、站点文件、数据库转储等)。他本可以这样做sudo do-release-upgrade
,但没有,他更愿意备份所有内容并进行全新安装。
问题是我现在有任务要把所有东西整理好,但现在sudo nginx -t
我却得到了这个语法错误:
nginx: [emerg] no port in upstream "memcached" in /etc/nginx/sites-enabled/forum.example.com:54
检查第 54 行以上,我看到"$scheme://$host$request_uri"
,这一定是先前在 nginx.conf 文件中配置过的……他忘记备份了。
我有一个 memcached 服务器,但我不知道如何/在哪里声明它。是在 nginx、conf 中,还是在站点的 .conf 文件中?
让我知道。
这是其余配置。还有其他问题吗?
提前致谢。
温暖的问候。
server {
listen 80;
server_name forum.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name forum.example.com;
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
root /usr/share/nginx/html/forum;
ssl on;
ssl_certificate /etc/letsencrypt/live/forum.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/forum.example.com/privkey.pem;
ssl_session_timeout 5m;
ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access-forum.log;
error_log /var/log/nginx/error-forum.log;
client_max_body_size 10m;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
location / {
index index.php index.htm index.html;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
set $memcached_key "$scheme://$host$request_uri";
memcached_pass memcached;
default_type text/html;
error_page 404 405 502 = @cache_miss;
}
location @cache_miss {
if (!-f $request_filename) { return 404; }
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 300;
}
location = /memcache.php {
if (!-f $request_filename) { return 404; }
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 300;
}
}