Synology Redirect Nginx HTTP to https + Allow Letsencrypt

You can follow this article pretty much all the way.

https://techjogging.com/redirect-www-to-https-in-synology-nas-nginx.html

However, it will fail if you use Letsencrypt to generate an SSL Certificate. So you simply need to add the following above the redirect line. Here’s how it should look.

server {
    listen 80 default_server{{#reuseport}} reuseport{{/reuseport}};
    listen [::]:80 default_server{{#reuseport}} reuseport{{/reuseport}};

    gzip on;
    
    location /.well-known/acme-challenge/ {
    # put your configuration here, if needed
    }

    server_name _;
    return 301 https://$host$request_uri;
}

Of course after you make this change you will need to restart Nginx

synoservicecfg --restart nginx

You can add as many locations as you like; once they’re matched, the request will not continue to the redirect at the end of the server {} container.

This was highlighted in the following Stack Overflow post.

https://serverfault.com/questions/874090/nginx-redirect-everything-except-letsencrypt-to-https

Live Blog – 07-27-2022 – Docker, PHP Package Oneliner

Docker + Speedtest Tracker

I love that I have a Synology since I can run my own Speedtest Tracker! I was having issues on Zoom and knew it was me as I have notifications set up when my ping or up/download speed drops. You can run this on pretty much anything, a raspberry pi or a spare mac. Just install docker, and you’re off to the races!

https://github.com/henrywhitaker3/Speedtest-Tracker

Install Multiple PHP packages based on Version

Want to install a bunch of PHP packages easily via CLI for a different PHP version.? Just run the following snippet. It works in bash and zsh, and can be used with apt and yum 🙂

apt-get install php74-{mbstring,mysql}

I required smartctl command from the smartmontools package under Ubuntu, and simply running apt-get install smartmontools resulted in some recommended packages to be installed suck as mail-utils and postfix of which I required neither.

There is an option with apt, which will not install recommended packages, its --no-install-recommends as you can see in the below example.

apt-get install --no-install-recommends smartmontools

SynoCommunity “Invalid location” error

When trying to install the SynoCommunity to your Synology’s package manager, you might get the “Invalid location” error, as shown in the screenshot below.

Excuse the location, this was from Google Images as I didn’t take a screenshot when the issue was occurring.

You can find the cause of this issue on the SynoCommunity Github, under the following issue.

https://github.com/SynoCommunity/spksrc/issues/4897

The root cause as explained by the creator of SynoCommunity

So yes after some testing on my end I can confirm that the trust certificates on a not fully updated DSM 6 are too old (a certificate must have expired recently). If you want to continue to stay on an old versions (not recommended obviously) you can update the trust store manually by overriding the file with a more recent one (assuming you trust the curl developers), using SSH: sudo mv /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt.bak && sudo curl -Lko /etc/ssl/certs/ca-certificates.crt https://curl.se/ca/cacert.pem This will fix the issue, alternatively you can set the clock back. The best solution however is to update to a more recent DSM6 version.

So if you’re running DSM6, update to the latest available version or DSM7 if supported. Otherwise, the following command will resolve the issue.

sudo mv /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt.bak && sudo curl -Lko /etc/ssl/certs/ca-certificates.crt https://curl.se/ca/cacert.pem

Sending email from Synology via CLI/SSH on DSM 6

Doing a quick Google search for sending emails from Synology via CLI/SSH talks about the sendmail command. However, this doesn’t work on DSM6 unless you install a package that provides the command.

You can install one of the following packages to get the sendmail command

  • Synology Mail Server
  • Synology MailPlus Server

Both allow you to set up an SMTP mail relay such as Gmail, Postmark, or Sendgrid. But that means you need to install and run these services. This is not ideal if you’re not using all the features of these applications.

Instead, you can look at using ssmtp which is installed by default and will use the built-in SMTP configuration that is present in the Synology Control Panel -> Notification -> Email.

You will have to make sure you use the appropriate email headers such as From: when piping in data to be sent via email like so.

echo "From: [email protected]\nthis is a test" | ssmtp [email protected]

You could also look at using Sendgrid or Postmark with Bash. There are two scripts that would work for this.

  • SendGrid

Clearing DNS Service Cache on Synology NAS

If you’re using the Synology DNS server for your local clients or services on the Synology NAS, then you might need to clear it’s cache.

It’s really simple, and after googling I couldn’t find a straight answer. So I did some digging and found this was the appropriate way to clear the DNS Service Cache on a DSM6.x

  1. Login via SSH as root
  2. Run “/var/packages/DNSServer/target/script/flushcache.sh”

ProxMox CIFS Share error “failed: error with cfs lock ‘file-storage_cfg'”

You may have encountered the following error message when trying to mount a CIFS share from the web interface of your Proxmox server. If you run the following command below via SSH, you will get a little more detail.

❯ pvesm add cifs pooter-linux-isos --server 192.168.2.9 --share linux-isos --username proxmox --password
Enter Password: *********
mount error(95): Operation not supported
create storage failed: error with cfs lock 'file-storage_cfg': mount error: Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

The issue is solved by running the command with –smbversion 2.0 or 2.1 or 3.0 as per this forum topic. For my Synology it was –smbversion 2.0 that worked.

https://forum.proxmox.com/threads/cifs-issue-error-with-cfs-lock-file-storage_cfg-working-now-but-shows-question-mark.45962/