Can’t use Certbot to SSL for Nginx with reactjs app and laravel subdirectory in subdomain

I have domain at 1 IP and subdomain at other IP. I had config nginx url for FE: http://subdomain/ and for BE: http://subdomain/api. And I need ssl for subdomain use Certbot, at this I have react app for FE and php laravel for BE all in docker, but not successfull.


server {
    listen 8888;
    server_name subdomain;

    index index.php index.html;
    root /var/www;
    client_max_body_size 256M;

    error_log /var/log/nginx/fe/error.log;
    access_log /var/log/nginx/fe/access.log;

    ## config path for API
    location ^~ /api  {
        error_log /var/log/nginx/api/error.log;
        access_log /var/log/nginx/api/access.log;

        alias /var/www/api/public;
        if (!-e $request_filename) {
            rewrite ^ /api/index.php last;
        location ~ .php$ {
            if (!-f $request_filename) {
                return 404;
            fastcgi_pass api:9000;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;

    location ~ /.well-known/acme-challenge {
        allow all;
        default_type "text/plain" ;
        alias /var/www/certbot/index.html; <-- #here only static file html with "HelloWorld"

    ## Load staic file for FE
    location / {
        try_files $uri /index.html;

And when I run verify ssl for nginx by Certbot:

certbot --nginx -d <subdomain> -m <email> 

I have error as bellow:

   Domain: <subdomain>
   Type:   unauthorized
   Detail: Invalid response from
   (IP): "<!DOCTYPE html>n<html lang="en">n<head>n
   <meta charset="UTF-8">n    <title>HelloWorld</title>n</head>n<body>nn</body>"

If I set block /.well-known/acme-challenge in nginx with only allow all; or allow all; root /certbot/index.html; I have error

   Domain: <subdomain>
   Type:   unauthorized
   Detail: Invalid response from
   (IP): "<html>rn<head><title>404 Not
   Found</title></head>rn<body>rn<center><h1>404 Not

How I can config nginx for ssl?

Thanks for support.

htaccess – Giving WordPress its own subdirectory – nginx

I want to move WordPress installation to a subdirectory without affecting site url – (method 1)

The article contains only instructions for Apache2. How would it translate to nginx site configuration?

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ my_subdir/index.php (L) 

windows – List each subdirectory and the number of files within it using cmd.exe

I have several subdirectories that contain files, and I want to list each subdirectory and beside it the number of files (*.html specifically) within that subdirectory. For example, I am in "C:Usersuser1Desktoptemp" and I want the following listing:

"C:Usersuser1Desktoptempsubdir1"  5 files
"C:Usersuser1Desktoptempsubdir2"  4 files
"C:Usersuser1Desktoptempsubdir2subdir1"  7 files

I tried using this code, but it only lists the number of files in the current directory:

dir /b *.html /s 2> nul | find "" /v /c > tmp && set /p count=<tmp && del tmp && echo %count%

directory – Cant get wordpress to work on subdirectory

I have an ubuntu server.

I already had nginx and some page there which works.

I wanted to add wordpress on /blog path

I installed wordpress using this setup

(I didnt start step 7 because i cant get the page to show up)

With the setup wordpress lives in /srv/www/wordpress where i see index.php and everything else

i did modify my nginx conf file

server {
  root /var/www/example;


  index index.html index.htm index.nginx-debian.html;


  location / {
    try_files $uri $uri/ =404;

  location ^~ /blog {
    root /srv/www/wordpress;
    index index.php;
    try_files $uri $uri/ /index.php?$args;

    location ~ .php$ {
        try_files $uri =404;
        include       fastcgi_params;


The new part is location ^~ /blog ... and i am unsure how it should look like.

Right now as it is if i go to the browser offers me to download some file. (its a short php file with the name “download”)

Thx for any suggestions

htaccess – I need to redirect an entire subdirectory in WordPress to the homepage – is this correct?

RewriteRule ^subfolder (R=301,L)

Strictly speaking this redirects any URLs that start /subfolder, including URLs of the form /subfolderfoo and /subfolderbar which obviously don’t fall “within the subdirectory”. And this is regardless of whether “subfolder” is a physical subdirectory on the filesystem or an entirely virtual (WordPress) URL-path. (If it was a physical subdirectory then you could create another .htaccess file in that subdirectory instead and “simplify” the rule.)

To redirect /subfolder and only URLs that are contained within that URL-path segment, eg. /subfolder/foo and /subfolder/bar, but not /subfolderfoo etc. then you should use the following instead:

RewriteRule ^subfolder($|/) (R=301,L)

Would I need to edit it to specifically work on WordPress?

This will work on WordPress as it would on any other Apache website.

However, it must go near the top of the .htaccess file, before the WordPress front-controller. ie. before the # BEGIN WordPress section. Otherwise, if /subfolder is a virtual URL-path, the directive will never be processed (since the request would be routed to the WordPress front-controller and processing stops).

You should test first with 302 (temporary) redirects to avoid potential caching issues.

apache 2.4 – Different PHP-FPM SetHandler proxy for subdirectory

I have a PHP website working well on “”, with “.php” files being proxied to a PHP-FPM socket.

I want to merge another website (on the same server) into a subdirectory of “”.

Here’s my virtual host (with irrelevant configs removed):

<VirtualHost *:443>
  DocumentRoot /opt/mydomain/
  UseCanonicalName Off

  <Directory />
    Require all granted
  <FilesMatch ".php$">
    SetHandler proxy:unix:/var/run/|fcgi://
  # new additions below:
  Alias /differentsite/ /opt/differentsite/
  <Directory "/opt/mydomain/differentsite/">
    <FilesMatch ".php$">
        SetHandler proxy:unix:/var/run/|fcgi://

I’m trying to reuse the same PHP-FPM socket that is currently being used for “”.

However, whether I change the order of the instructions, or try without “Alias”, or just “Alias” alone, create a symlink, etc;
I’m unable to get it to proxy to the “differentsite” socket.

I get No input file specified., or just a normal 404 in the main root site, or it actually downloads the PHP source (if I remove the main root SetHandler), etc…

How can I force any request on “” be 100% proxied to the other PHP-FPM socket?

export – Exporting a file into a subdirectory of notebook

I suppose that by “a directory in a notebook directory” you mean “the directory of the notebook where the Export is evaluated”. Of course the notebook should first be saved somewhere.
Then do :

Export(FileNameJoin({NotebookDirectory(), "newDirectory", 
   "testFile55.jpg"}), ConstantImage(Red))  

The “newDirectory” wil be created as part of the file creation (no need to create the directory separately first).

The Mathematica Version should not be to old.

users – Get current uid from a subdirectory of Drupal root

I need to use the uid of the currently logged in user in an external PHP file in a subdirectory of Drupal (8.9). I was pointed to this code:


use DrupalCoreDrupalKernel;
use SymfonyComponentHttpFoundationRequest;

$autoloader = require_once 'autoload.php';
$request = Request::createFromGlobals();
print_r($request->cookies);             // ... ( ... ( (SSESSabfa7...) => _Eu_28jS3Vr8Y... ))
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');

$container = $kernel->getContainer();
// Ensure our request includes the session.
// Authenticate the user, see AuthenticationSubscriber::onKernelRequestAuthenticate().
$account = $container->get('authentication')->authenticate($request);
if ($account) {


It works fine in the root directory, but I didn’t get it work in a subdirectory. The resulting uid is “0”.
I tried to use chdir('root directory'); for instance, but it didn’t help.

nginx – URLs behind a Reverse Proxy of subdirectory starting with ‘/’

I have nginx acting as a reverse proxy. URLs of the form are proxied to the internal server listening at http://localhost:8080/.

location /dir/ {

Links in that server are handled fine if they do not begin with a initial /. Those that do point to rather than Is there any way, without altering the server’s code, to fix this so links on that server behave as desired (e.g. act like they would if they weren’t behind this proxied subdirectory).

Basically I’d want to set up nginx so that the server behind the proxy will to be able to use the same code whether it is a proxied subdirectory or on its own subdomain.