upstream php73 {
    server php73:9000;
}

upstream php74 {
    server php74:9000;
}

map $http_host $root {
    loc.octobercms /usr/share/nginx/html/someproject;
    loc.wordpress /usr/share/nginx/html/someprojectwp;
}

# @see https://github.com/OFFLINE-GmbH/oc-responsive-images-plugin/#responsive-images
map $http_accept $webp_suffix {
    default   "";
    "~*webp"  ".webp";
}

server {
    server_name
        loc.octobercms
    ;
    listen 80;
    root $root;
    #include global/auth.conf;
    #@see https://vcs.wpstudio.ru/wpstudio/nginx-examples
    include includes.d/octobercms.conf;
    include includes.d/staticfiles.conf;
    location ~ ^/index.php {
        fastcgi_pass php74;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SERVER_NAME     $host;
    }
}

server {
    server_name
        loc.octobercmswebp
    ;
    listen 80;
    root $root;
    include includes.d/octobercms.conf;
    include includes.d/offline-webp.conf;
    include includes.d/staticfiles.conf;
    location = /index.php {
        fastcgi_pass php74;
        include fastcgi_params;
        fastcgi_read_timeout 3000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
    location = /plugins/offline/responsiveimages/webp.php {
        fastcgi_pass php74;
        include fastcgi_params;
        fastcgi_read_timeout 3000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

server {
    server_name loc.wordpress;
    listen 80;
    root $root;
    index index.html index.htm index.php;
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        access_log off;
    }
    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {
          return 404;
        }
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        fastcgi_param SERVER_NAME     $host;

        fastcgi_pass   php73;
        fastcgi_index  index.php;
    }
}