DSM6 : Configure Nginx for WordPress permalinks (avoid 404)

With the Synology DSM6 update, we have now to use Nginx instead of Apache. By default Nginx configuration don’t allow wordpress permalinks (generate 404).

I read the idea was to transform the /uri in /?p=$uri and put this configuration in the “location” section of the server nginx config.

Read More

Where to put this configuration in DSM6 exactly ?

Related posts

2 comments

  1. Have you tried the user config? Just copy your working:

    /etc/nginx/app.d/server.webstation-vhost.conf
    

    to:

    /usr/local/etc/nginx/sites-enabled/httpd-vhost.conf-user
    

    and rename the server.webstation-vhost.conf to server.webstation-vhost.conf.old or something and restart nginx (nginx -s reload)

    Or better yet, remove your virtual host(s) from webstation. Only thing is you need to manually update your SSL certs when they expire instead of using the web interface.

  2. Actually, you can add custom directives easily, without modifying the DSM behavior.

    Take a look at the content of /usr/local/etc/nginx/sites-enabled/httpd-vhost.conf-user, to see where the custom configuration has to be stored:

    server {
        [...]
        server_name NAME
        [...]
    
        include /usr/local/etc/nginx/conf.d/778943ad-0dc4-40ae-bb7f-7b2285e3203b/user.conf*;
    }
    

    Then, you just have to create the file /usr/local/etc/nginx/conf.d/778943ad-0dc4-40ae-bb7f-7b2285e3203b/user.conf.wordpress-permalink with the following content:

    location /{
    try_files $uri $uri/ /index.php?$args;
    }
    

    and restart nginx:

    synoservicecfg --restart nginx
    

    It will not break the future DSM update (since it is a supported customization)

Comments are closed.