Support » Plugin: Multiple Domain Mapping on Single Site » Support with wordpress running on nginx server

  • Resolved Jagan Krishnaraj

    (@jagan-krishnaraj)


    I went through all the support documents.

    Found out this thread which is 3 years old
    https://wordpress.org/support/topic/work-with-nginx-2/

    It says this plugin work with nginx.

    I use the nginx/1.18.0 version on ubuntu 18. I couldn’t get it to work with the default configuration.

    All new mappings REDIRECT to the home page by default, not show the mapped page

    So you support WordPress running on Nginx server in 2021?

    Is there documentation for rules and configurations that should be used with nginx to make it work?

    this plugin works great with apache as plug and play, not with nginx.

    Any support is greatly appreciated.

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author matthias.wagner

    (@matthiaswagner)

    hy jagan,

    first of all: thank you for helping other users in other threads 🙂

    we do not use nginx for ourselves, that’s why we cannot really provide support. as you can see in the linked thread, we assume that there should not be any problems since the plugin does not work with htaccess but only php stuff to alter the wordpress queries.

    i guess the first thing should be to ensure all 4 steps in “external setup” are done and tested: https://wordpress.org/plugins/multiple-domain-mapping-on-single-site/#installation

    if you see redirections here (best is to try without plugin activated), they would come from your server.

    good luck and keep us updated 😉

    matt

    Thread Starter Jagan Krishnaraj

    (@jagan-krishnaraj)

    Thank you for your response.

    I figured it out.

    I did a clean Ubuntu 20 installation on an AWS instance.
    Installed PHP 7.4 & WordPress 5.7.2
    With the default configuration, it didn’t work, however when I updated the option from
    $_SERVER[“SERVER_NAME”] to _SERVER[“HTTP_HOST”] it started working right away.

    So your plugin supports nginx/1.18.0 server on PHP 7.4 running on ubuntu 20.

    This is in the best test-case scenario. To make it work in my actual production environment is going to be a lot of work, but it’s possible.

    There is hope.

    In your documentation, you can consider include this line
    For the Nginx server,
    $_SERVER[“HTTP_HOST”] should be the default setting.

    Thanks again.
    If we get something for free, we should give back too.

    Thread Starter Jagan Krishnaraj

    (@jagan-krishnaraj)

    For those who are working with Nginx, this is the example configuration file that worked on the production server.

    server {
        if ($host = www.YourName.com) {
            return 301 https://$host$request_uri;
        } 
        if ($host = YourName.com) {
            return 301 https://$host$request_uri;
        } 
        listen 80;
        listen [::]:80;
        server_name YourName.com *.YourName.com;
        if ($http_host ~ "^(.+)\.YourName\.com$"){
            set $http_host_1 $1;
            rewrite ^(.*)$ https://$http_host_1.YourName.com$1 redirect;
        }
    }
    server {
        listen  443 ssl;
        listen [::]:443 ssl;
        server_name www.YourName.com;
        ssl_certificate /home/ubuntu/.acme.sh/YourName.com/fullchain.cer;
        ssl_certificate_key /home/ubuntu/.acme.sh/YourName.com/YourName.com.key;
        return 301 https://YourName.com$request_uri;
    }
    server {
        listen  443 ssl;
        listen [::]:443 ssl;
        server_name YourName.com *.YourName.com;
        root /var/www/domains/ROOTFOLDERPATH;
        index index.html index.htm index.php index.nginx-debian.html;
        location / {
         try_files $uri $uri/ /index.php?$args;
        }
        location ~ \.php$ {
         include snippets/fastcgi-php.conf;
            fastcgi_read_timeout            3600s;
            fastcgi_buffer_size             128k;
            fastcgi_buffers                 4 128k;
            fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
       }
        ssl_certificate /home/ubuntu/.acme.sh/YourName.com/fullchain.cer;
        ssl_certificate_key /home/ubuntu/.acme.sh/YourName.com/YourName.com.key;
    }

    Provided, the default variable on “Additional settings” is set to
    $_SERVER[“HTTP_HOST”]

    Plugin Author matthias.wagner

    (@matthiaswagner)

    thank you for your hints!
    we have added some information about your nginx-experience in the description of the plugin 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.