clarkwinkelmann Thank you! I tried that, and I moved the WordPress folder inside flarum folder (i.e., the root directory), but it is the same. The configuration now is:
# Default server configuration
#
server {
root /var/www/example.com/html/flarum;
include /var/www/example.com/html/flarum/.nginx.conf;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location /wordpress {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
# Flarum Support
location ~ \.php$ {
root /var/www/example.com/html/flarum;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
}
location = /sitemap.xml {
try_files $uri $uri/ /index.php?$query_string;
}
# deny access to .htaccess files, if Apache's document root
# concurs with Nginx's one
#
location ~ /\.ht {
deny all;
}
## We added these rules
# Protect my wordpress login page and directory with a password
location = /wordpress/wp-login.php {
auth_basic "Login";
include snippets/fastcgi-php.conf;
auth_basic_user_file /etc/nginx/.htpasswd;
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
}
#Block All XML-RPC Traffic
location /xmlrpc.php {
deny all;
}
#Stop favicon logging
location = /favicon.ico {
log_not_found off;
access_log off;
}
#Allow robots traffic
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
#Session Caching
ssl_session_cache shared:SSL:20m;
#OCSP Stapling
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
#End of the rules we added
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/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
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 404; # managed by Certbot
}
I hope the subfolder works as the subdomain is my last resort. Again, thank you for all of your help.