Permanent Redirect with exception for .well-known/... (WKD)

Discussion in 'Installation/Configuration' started by fandreas, Jul 30, 2024.

  1. fandreas

    fandreas New Member

    Hello,

    I have a permanent redirect configured for a Website and try to configure an exception for the folder .well-known/openpgpkeys and any subfolders and files. It's about Web Key Directory (WKD), a solution to exchange PGP keys for mail encryption. Due to forum restrictions I am not able to provide a link with more details about WKD. Sorry.

    I created the .well-known folder and subfolders in the webroot directory and tried some rewrite rules, which I googled. I am by no means an expert for regular expressions or nginx rewrite rules. I am also not sure if this is the right direction?

    Maybe someone has a friendly hint for me?

    Regards
    Andreas
     
  2. fandreas

    fandreas New Member

    I managed to solve this problem myself.

    1. Copied nginx_vhost.conf.master to conf-custom folder and added the following lines to it:
    location ^~ /.well-known/openpgpkey {
    default_type application/octet-stream;
    add_header Access-Control-Allow-Origin * always;
    }
    2. Added the follwoing rewrite rule to site configuration in Redirect tab:
    rewrite ^(?!/(\.well-known))/(.*)$ URL$2 permanent;
    3. Reinitialized site configuration by changing some small value to reload nginx_vhost.conf.master for the corresponding site.
    Works.
    The only thing I am not quite sure is, if let's encrypt renewals are in any way affected. Don't hope so.
     

Share This Page