我猜这是由我的nginx配置引起的,但是我不太清楚如何进行故障排除以解决问题。
我正在使用带有LEMP堆栈的Ubuntu 20.04来托管wordpress安装。除了这个怪癖之外,一切都很好。这个怪癖是,如果我在Chrome中键入网站的URL,网站将解析为\'https://example.com“网站上的一切都很好。
然而,在Firefox中,如果我键入网站的URL,它将解析为\'https://www.example.com,这将是好的,除了网站上的某些图标现在将不会加载,不会显示,并由一个方形框代替。
下面是我正在使用的nginx配置:
server {
listen 80;
server_name www.{{ domain_name }}{{ tld }} {{ domain_name }}{{ tld }};
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name www.{{ domain_name }}{{ tld }};
ssl_certificate /etc/letsencrypt/certs/fullchain_{{ domain_name }};
ssl_certificate_key /etc/letsencrypt/keys/{{ domain_name }}.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM;
# ssl_ecdh_curve secp521r1;
root /home/{{ domain_name }}/public_html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
# return 301 https://www.$server_name$request_uri;
location ~ \\.php$ {
# Basic
try_files $uri =404;
fastcgi_index index.php;
# Create a no cache flag
set $no_cache "";
# Don\'t ever cache POSTs
if ($request_method = POST) {
set $no_cache 1;
}
# Admin stuff should not be cached
if ($request_uri ~* "/(wp-admin/|wp-login.php)") {
set $no_cache 1;
}
# WooCommerce stuff should not be cached
if ($request_uri ~* "/store.*|/cart.*|/my-account.*|/checkout.*|/addons.*") {
set $no_cache 1;
}
# If we are the admin, make sure nothing
# gets cached, so no weird stuff will happen
if ($http_cookie ~* "wordpress_logged_in_") {
set $no_cache 1;
}
# Cache and cache bypass handling
fastcgi_no_cache $no_cache;
fastcgi_cache_bypass $no_cache;
fastcgi_cache microcache;
fastcgi_cache_key $scheme$request_method$server_name$request_uri$args;
fastcgi_cache_valid 200 60m;
fastcgi_cache_valid 404 10m;
fastcgi_cache_use_stale updating;
# General FastCGI handling
fastcgi_pass unix:/var/run/php/{{ domain_name }}.sock;
fastcgi_pass_header Set-Cookie;
fastcgi_pass_header Cookie;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_split_path_info ^(.+\\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_intercept_errors on;
include fastcgi_params;
}
location ~* \\.(js|css|png|jpg|jpeg|gif|ico|woff|ttf|svg|otf)$ {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
access_log off;
}
}