主域名 - imagecompressor.io,子域名 - dev.imagecompressor.io
内容配置似乎不适用于子域。对两者均curl
返回200 OK
,但文件仅针对主域下载。对于子域,请求将转发到 reactjs 前端应用程序。
https://imagecompressor.io/images/Logo.png- 作品
https://dev.imagecompressor.io/images/Logo.png- 不起作用
NGINX 配置 - 域
server {
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/imagecompressio-js/serve;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name imagecompressor.io;
# error_log /var/log/nginx/error.log debug;
location /images {
alias /var/www/images;
add_header Last-Modified $date_gmt;
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
if_modified_since off;
expires off;
etag off;
add_header Content-disposition "attachment; filename=$1";
}
location /files {
alias /var/www/files;
expires 3d;
add_header Cache-Control public;
add_header Content-disposition "attachment; filename=$1";
}
location ^~ /blog {
root /var/www/;
try_files $uri $uri/ =404;
}
location = /blog/mozjpeg-guide/compress {
return 301 /blog/mozjpeg-guide;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri /index.html =404;
expires -1;
}
location ~* \.(?:css|js)$ {
access_log off;
log_not_found off;
add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate";
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/imagecompressor.io/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/imagecompressor.io/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
NGINX 配置 - 子域名
server {
root /var/www/imagecompressio-js/serve;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name dev.imagecompressor.io;
error_log /var/log/nginx/error.log debug;
location /images {
alias /var/www/images;
add_header Last-Modified $date_gmt;
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
if_modified_since off;
expires off;
etag off;
add_header Content-disposition "attachment; filename=$1";
}
location /files {
alias /var/www/files;
expires 3d;
add_header Cache-Control public;
add_header Content-disposition "attachment; filename=$1";
}
location ^~ /blog {
root /var/www/;
try_files $uri $uri/ =404;
}
location = /blog/mozjpeg-guide/compress {
return 301 /blog/mozjpeg-guide;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri /index.html =404;
expires -1;
}
location ~* \.(?:css|js)$ {
access_log off;
log_not_found off;
expires 30d;
add_header Cache-Control "no-cache, public, must-revalidate, proxy-revalidate";
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/dev.imagecompressor.io/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/dev.imagecompressor.io/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
curl
输出
dev.imagecompressor.io
curl --head https://dev.imagecompressor.io/images/Logo.png
HTTP/1.1 200 OK
Server: nginx/1.10.3
Date: Tue, 21 Jul 2020 21:10:07 GMT
Content-Type: image/png
Content-Length: 6865
Connection: keep-alive
Last-Modified: Tuesday, 21-Jul-2020 21:10:07 GMT
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0
Content-disposition: attachment; filename=
Accept-Ranges: bytes
图像压缩器
curl --head https://imagecompressor.io/images/Logo.png
HTTP/1.1 200 OK
Server: nginx/1.10.3
Date: Tue, 21 Jul 2020 21:15:00 GMT
Content-Type: image/png
Content-Length: 6865
Connection: keep-alive
Last-Modified: Tuesday, 21-Jul-2020 21:15:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0
Content-disposition: attachment; filename=
Accept-Ranges: bytes
完全一样。不知道这里的问题是什么。