[Bug]: Unable to display images directly through a direct link
⚠️ This issue respects the following points: ⚠️
- [X] This is a bug, not a question or a configuration/webserver/proxy issue.
- [X] This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- [X] Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- [X] I agree to follow Nextcloud's Code of Conduct.
Bug description
When I upgraded Nextcloud from V27 to V29, I couldn't display images directly through the direct link https://6.glxaa.com:11224/s/iCe3tfSy52Bnfk3/preview When displayed:
But without the suffix 'preview', it can be displayed normally:
Steps to reproduce
- Runs well on NextCloud27 version
- Upgrade to V28, upgrade to V29
- Images cannot be accessed through direct links
Expected behavior
Images can be accessed through direct links
Installation method
Community Manual installation with Archive
Nextcloud Server version
29
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.2
Web server
Nginx
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Upgraded to a MAJOR version (ex. 28 to 29)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- [X] Default user-backend (database)
- [ ] LDAP/ Active Directory
- [ ] SSO - SAML
- [ ] Other
Configuration report
root@ubuntu:/var/www/nextcloud# sudo -u www-data php occ config:list system
{
"system": {
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"glxaa.com:11224",
"10.0.0.2:11224",
"6.glxaa.com:11224",
"10.1.1.2:11224",
"172.27.131.203:11224",
"10.1.1.1:11224",
"10.0.0.10:11224",
"172.26.106.11:11224"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "mysql",
"version": "29.0.4.1",
"overwrite.cli.url": "https:\/\/10.0.0.2:11224",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"mysql.utf8mb4": true,
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"memcache.local": "\\OC\\Memcache\\APCu",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"memcache.locking": "\\OC\\Memcache\\Redis",
"redis": {
"host": "***REMOVED SENSITIVE VALUE***",
"port": 6379,
"password": "***REMOVED SENSITIVE VALUE***"
},
"mail_from_address": "***REMOVED SENSITIVE VALUE***",
"mail_smtpmode": "smtp",
"mail_sendmailmode": "smtp",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"mail_smtphost": "***REMOVED SENSITIVE VALUE***",
"mail_smtpport": "25",
"mail_smtpauth": 1,
"mail_smtpname": "***REMOVED SENSITIVE VALUE***",
"mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
"appstoreenabled": true,
"appstoreurl": "https:\/\/www.orcy.net\/ncapps\/v1\/",
"twofactor_enforced": "false",
"twofactor_enforced_groups": [],
"twofactor_enforced_excluded_groups": [],
"default_phone_region": "CN",
"default_language": "zh_CN",
"default_locale": "zh",
"enable_previews": true,
"enabledPreviewProviders": [
"OC\\Preview\\TXT",
"OC\\Preview\\MarkDown",
"OC\\Preview\\OpenDocument",
"OC\\Preview\\PDF",
"OC\\Preview\\MSOffice2003",
"OC\\Preview\\MSOfficeDoc",
"OC\\Preview\\PDF",
"OC\\Preview\\Image",
"OC\\Preview\\Photoshop",
"OC\\Preview\\TIFF",
"OC\\Preview\\SVG",
"OC\\Preview\\Font",
"OC\\Preview\\MP3",
"OC\\Preview\\Movie",
"OC\\Preview\\MKV",
"OC\\Preview\\MP4",
"OC\\Preview\\AVI",
"OC\\Preview\\EMF",
"OC\\Preview\\Krita",
"OC\\Preview\\Imaginary",
"OC\\Preview\\WEBP",
"OC\\Preview\\PNG",
"OC\\Preview\\JPEG"
],
"preview_imaginary_url": "***REMOVED SENSITIVE VALUE***",
"preview_format": "webp",
"ncd_admin_settings": {
"disallow_aria2_settings": "0",
"ncd_aria2_rpc_host": "10.1.1.4",
"focusVisibleAdded": "",
"ncd_aria2_rpc_port": "6800"
},
"maintenance": false,
"loglevel": 2,
"updater.release.channel": "stable",
"theme": "",
"maintenance_window_start": 1,
"app_install_overwrite": []
}
}
root@ubuntu:/var/www/nextcloud#
List of activated Apps
root@ubuntu:/var/www/nextcloud# sudo -u www-data php occ app:list
Enabled:
- activity: 2.21.1
- admin_audit: 1.19.0
- bruteforcesettings: 2.9.0
- cfg_share_links: 5.1.0
- circles: 29.0.0-dev
- cloud_federation_api: 1.12.0
- comments: 1.19.0
- contactsinteraction: 1.10.0
- dashboard: 7.9.0
- dav: 1.30.1
- drawio: 3.0.2
- federatedfilesharing: 1.19.0
- federation: 1.19.0
- files: 2.1.0
- files_external: 1.21.0
- files_markdown: 2.4.1
- files_pdfviewer: 2.10.0
- files_reminders: 1.2.0
- files_sharing: 1.21.0
- files_trashbin: 1.19.0
- files_zip: 1.6.0
- firstrunwizard: 2.18.0
- limit_login_to_ip: 4.1.0
- logreader: 2.14.0
- lookup_server_connector: 1.17.0
- nextcloud_announcements: 1.18.0
- notifications: 2.17.0
- oauth2: 1.17.0
- password_policy: 1.19.0
- photos: 2.5.0
- previewgenerator: 5.6.0
- privacy: 1.13.0
- provisioning_api: 1.19.0
- recommendations: 2.1.0
- related_resources: 1.4.0
- richdocuments: 8.4.3
- serverinfo: 1.19.0
- settings: 1.12.0
- sharebymail: 1.19.0
- support: 1.12.0
- suspicious_login: 7.0.0
- systemtags: 1.19.0
- text: 3.10.1
- theming: 2.4.0
- twofactor_backupcodes: 1.18.0
- twofactor_totp: 11.0.0-dev
- updatenotification: 1.19.1
- user_status: 1.9.0
- viewer: 2.3.0
- weather_status: 1.9.0
- workflowengine: 2.11.0
Disabled:
- encryption: 2.17.0
- files_downloadlimit: 2.0.0 (installed 2.0.0)
- files_versions: 1.22.0 (installed 1.20.0)
- picker: 1.0.8 (installed 1.0.8)
- richdocumentscode: 24.4.502 (installed 24.4.502)
- spreed: 19.0.7 (installed 19.0.7)
- survey_client: 1.17.0 (installed 1.17.0)
- user_ldap: 1.20.0
root@ubuntu:/var/www/nextcloud#
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
{"reqId":"YA4yO28E5Ag7Ie9ZyIVN","level":2,"time":"2024-08-02T17:07:26+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Host 10.1.1.2 was not connected to because it violates local access rules","userAgent":"--","version":"29.0.4.1","data":[]}
{"reqId":"YA4yO28E5Ag7Ie9ZyIVN","level":2,"time":"2024-08-02T17:07:26+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Host 10.1.1.2 was not connected to because it violates local access rules","userAgent":"--","version":"29.0.4.1","data":[]}
{"reqId":"YA4yO28E5Ag7Ie9ZyIVN","level":2,"time":"2024-08-02T17:07:28+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Host 10.1.1.2 was not connected to because it violates local access rules","userAgent":"--","version":"29.0.4.1","data":[]}
Additional info
I hope this issue can be resolved so that I can confidently upgrade Nextlcoud to the new version. Thanks.
It seems to work for me.
Are you sure your Nginx config is up-to-date? There are changes required for >=v28 as noted in the Critical Changes section of the Release Notes: https://docs.nextcloud.com/server/latest/admin_manual/release_notes/index.html
它似乎对我有用。
您确定您的 Nginx 配置是最新的吗?>=v28 需要进行更改,如发行说明中的关键更改部分所述:https://docs.nextcloud.com/server/latest/admin_manual/release_notes/index.html
Thank you for your reply. Before upgrading to version 28, I did not make any changes to the nginx configuration file. After your reminder, I compared it with the official recommended nginx configuration and made some modifications. The following is my nginx configuration, but the result is that it still cannot display the image in a direct link format, it displays a '[]'.
I noticed on NextCloud30 that:
Make sure that your web server is serving files with the webp extension (WebP images) correctly as static assets. This is included in the shipped .htaccess file but if you use another web server or custom configuration you need to check this manually.
I am wondering if it is due to a static resource configuration issue with my webp. Could you please help me check if it is an nginx configuration issue? Thank you very much.
upstream php-handler {
#server 127.0.0.1:9000;
server unix:/run/php/php8.2-fpm.sock;
}
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
map $arg_v $asset_immutable {
"" "";
default "immutable";
}
#server {
# listen 80;
# listen [::]:80;
# server_name 10.0.0.2;
# Prevent nginx HTTP Server Detection
# server_tokens off;
# Enforce HTTPS
# return 301 https://$server_name$request_uri;
#}
server {
listen 11224 ssl http2;
listen [::]:11224 ssl http2;
server_name 10.0.0.2;
# Path to the root of your installation
root /var/www/nextcloud;
# Use Mozilla's guidelines for SSL/TLS settings
# https://mozilla.github.io/server-side-tls/ssl-config-generator/
ssl_certificate /opt/ssl/fullchain.cer;
ssl_certificate_key /opt/ssl/cert.key;
# Prevent nginx HTTP Server Detection
server_tokens off;
# HSTS settings
# WARNING: Only add the preload option once you read about
# the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# in all major browsers and getting removed from this list
# could take several months.
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;
# set max upload size and increase upload timeout:
client_max_body_size 5120000M;
client_body_timeout 300s;
fastcgi_buffers 128 8K;
# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
# Pagespeed is not supported by Nextcloud, so if your server is built
# with the `ngx_pagespeed` module, uncomment this line to disable it.
#pagespeed off;
# The settings allows you to optimize the HTTP2 bandwidth.
# See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
# for tuning hints
client_body_buffer_size 512k;
# HTTP response headers borrowed from Nextcloud `.htaccess`
add_header Strict-Transport-Security 'max-age=15552000' always;
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "noindex, nofollow" always;
add_header X-XSS-Protection "1; mode=block" always;
#获取客户端真实ip
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;
# Add .mjs as a file extension for javascript
# Either include it in the default mime.types list
# or include you can include that list explicitly and add the file extension
# only for Nextcloud like below:
include mime.types;
types {
# text/javascript js mjs;
text/javascript mjs ;
application/wasm wasm;
}
# Specify how to handle directories -- specifying `/index.php$request_uri`
# here as the fallback means that Nginx always exhibits the desired behaviour
# when a client requests a path that corresponds to a directory that exists
# on the server. In particular, if that directory contains an index.php file,
# that file is correctly served; if it doesn't, then the request is passed to
# the front-end controller. This consistent behaviour means that we don't need
# to specify custom rules for certain paths (e.g. images and other assets,
# `/updater`, `/ocs-provider`), and thus
# `try_files $uri $uri/ /index.php$request_uri`
# always provides the desired behaviour.
index index.php index.html /index.php$request_uri;
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
location = / {
if ( $http_user_agent ~ ^DavClnt ) {
return 302 /remote.php/webdav/$is_args$args;
}
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Make a regex exception for `/.well-known` so that clients can still
# access it despite the existence of the regex rule
# `location ~ /(\.|autotest|...)` which would otherwise handle requests
# for `/.well-known`.
location ^~ /.well-known {
location = /.well-known/webfinger { return 301 $scheme://$host:$server_port/index.php/.well-known/webfinger; }
location = /.well-known/nodeinfo {return 301 $scheme://$host:$server_port/index.php/.well-known/nodeinfo;}
location = /.well-known/carddav { return 301 $scheme://$host:$server_port/remote.php/dav/; }
location = /.well-known/caldav { return 301 $scheme://$host:$server_port/remote.php/dav/; }
try_files $uri $uri/ =404;
}
# Rules borrowed from `.htaccess` to hide certain paths from clients
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
# Ensure this block, which passes PHP files to the PHP process, is above the blocks
# which handle static assets (as seen below). If this block is not declared first,
# then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
# to the URI, resulting in a HTTP 500 error response.
location ~ \.php(?:$|/) {
# Required for legacy support
# rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode\/proxy) /index.php$request_uri;
rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
fastcgi_param front_controller_active true; # Enable pretty urls
fastcgi_pass php-handler;
fastcgi_read_timeout 86400;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
fastcgi_max_temp_file_size 0;
}
# Serve static files
#location ~ \.(?:css|js|mjs|webp|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
# try_files $uri /index.php$request_uri;
# add_header Cache-Control "public, max-age=15778463, $asset_immutable";
# access_log off; # Optional: Don't log access to assets
# location ~ \.wasm$ {
default_type application/wasm;
# }
#}
location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mjs)$ {
try_files $uri /index.php$request_uri;
# HTTP response headers borrowed from Nextcloud `.htaccess`
add_header Cache-Control "public, max-age=15778463$asset_immutable";
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "noindex, nofollow" always;
add_header X-XSS-Protection "1; mode=block" always;
access_log on; # Optional: Don't log access to assets
}
location ~ \.woff2?$ {
try_files $uri /index.php$request_uri;
expires 7d; # Cache-Control policy borrowed from `.htaccess`
access_log off; # Optional: Don't log access to assets
}
# Rule borrowed from `.htaccess`
location /remote {
return 301 /remote.php$request_uri;
}
location / {
try_files $uri $uri/ /index.php$request_uri;
}
}
I rolled back NextCloud from 29 to 27 and upgraded it again to 29, but this issue no longer occurs.