Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple domains and multiple php-fpm pools conflicting! #34

Closed
IbrahimS2 opened this issue Apr 5, 2020 · 2 comments
Closed

Multiple domains and multiple php-fpm pools conflicting! #34

IbrahimS2 opened this issue Apr 5, 2020 · 2 comments

Comments

@IbrahimS2
Copy link

IbrahimS2 commented Apr 5, 2020

For some reason when running multiple domains/vhosts it is conflicting and it does not pass the relevant PHP pool?

Now I have created two maps.conf as each domain will have multiple domains/stores.

Now the issue is domain1 using xxxxx pool and when I var_dump

$params = $_SERVER;
var_dump($_SERVER);
exit;

For domain1 it returns the following:

array(
   39)   {
[
         "USER"
      ]      => string(9)      "xxxxxx"[
         "HOME"
      ]      => string(15)      "/home/xxxxxx"[
         "HTTP_COOKIE"
      ]      => string(340)      "_ga=GA1.3.2089969139.1586092654; _gid=GA1.3.1706564775.1586092654; _fbp=fb.2.1586092653868.278218693; _hjid=e84418d7-c956-41fc-9e4e-d5c6022e4160; mage-cache-storage=%7B%7D; mage-cache-storage-section-invalidation=%7B%7D; _hjIncludedInSample=1; X-Magento-Vary=e3cb9ab3566a693edff3edf82caa39b1ed79e8ba; section_data_ids=%7B%22gtm%22%3A7000%7D"[
         "HTTP_ACCEPT_LANGUAGE"
      ]      => string(23)      "en-GB,en;q=0.9,ar;q=0.8"[
         "HTTP_ACCEPT_ENCODING"
      ]      => string(17)      "gzip, deflate, br"[
         "HTTP_SEC_FETCH_USER"
      ]      => string(2)      "?1"[
         "HTTP_SEC_FETCH_MODE"
      ]      => string(8)      "navigate"[
         "HTTP_SEC_FETCH_SITE"
      ]      => string(4)      "none"[
         "HTTP_ACCEPT"
      ]      => string(124)      "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"[
         "HTTP_SEC_FETCH_DEST"
      ]      => string(8)      "document"[
         "HTTP_USER_AGENT"
      ]      => string(115)      "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36"[
         "HTTP_UPGRADE_INSECURE_REQUESTS"
      ]      => string(1)      "1"[
         "HTTP_DNT"
      ]      => string(1)      "1"[
         "HTTP_CACHE_CONTROL"
      ]      => string(9)      "max-age=0"[
         "HTTP_HOST"
      ]      => string(20)      "www.xxxxxx.co.uk"[
         "MAGE_RUN_TYPE"
      ]      => string(0)      ""[
         "MAGE_RUN_CODE"
      ]      => string(0)      ""[
         "REDIRECT_STATUS"
      ]      => string(3)      "200"[
         "SERVER_NAME"
      ]      => string(15)      "www.xxxxxx.com"[
         "SERVER_ADDR"
      ]      => string(15)      "000.000.000.000"[
         "REMOTE_PORT"
      ]      => string(5)      "41721"[
         "REMOTE_ADDR"
      ]      => string(13)      "000.000.000.000"[
         "SERVER_SOFTWARE"
      ]      => string(12)      "nginx/1.16.1"[
         "GATEWAY_INTERFACE"
      ]      => string(7)      "CGI/1.1"[
         "HTTPS"
      ]      => string(2)      "on"[
         "SERVER_PROTOCOL"
      ]      => string(8)      "HTTP/2.0"[
         "DOCUMENT_ROOT"
      ]      => string(24)      "/home/xxxxxx/public/pub"[
         "DOCUMENT_URI"
      ]      => string(10)      "/index.php"[
         "REQUEST_URI"
      ]      => string(1)      "/"[
         "SCRIPT_NAME"
      ]      => string(10)      "/index.php"[
         "SCRIPT_FILENAME"
      ]      => string(34)      "/home/xxxxx/public/pub/index.php"[
         "CONTENT_LENGTH"
      ]      => string(0)      ""[
         "CONTENT_TYPE"
      ]      => string(0)      ""[
         "REQUEST_METHOD"
      ]      => string(3)      "GET"[
         "QUERY_STRING"
      ]      => string(0)      ""[
         "FCGI_ROLE"
      ]      => string(9)      "RESPONDER"[
         "PHP_SELF"
      ]      => string(10)      "/index.php"[
         "REQUEST_TIME_FLOAT"
      ]      => float(1586095624.6495)[
         "REQUEST_TIME"
      ]      => int(1586095624)
   }

How come Domain1 returning domain2 details? including the ownership etc...

domain-maps.conf

## Map php-fpm pass route
map $http_host$request_uri $MAGE_PHP_ROUTE {
    default unix:/var/run/php7.2-fpm-domain1.sock; # default php-fpm
}

    ## Map files to exclude from access log
#    map $request $writelog {
#                default   1;
#                ~*\.woff2 0;
#                ~*\.jpg   0;
#                ~*\.png   0;
#                ~*\.gif   0;
#                ~*\.css   0;
#                ~*\.webp  0;
#                ~*\.js    0;
#        }

## map query parameter to magento profiler parameter
map $query_string $MAGE_PROFILER {
  ~DEVELOPMENT=Q9ARzXbrwI html;
}

## Filter API access
map $request_uri $api_access {
            default 0;
        ~/(.*)/V1/customers(?!/me)              1;
	~/(.*)/V1/customers/password            1;
        ~/(.*)/V1/customers/resetPassword       1;
        ~/(.*)/V1/customers/isEmailAvailable    1;
        ~/(.*)/V1/guest-carts/                  1;
        ~/(.*)/V1/integration/                  1;
        ~/(.*)/V1/search                        1;
    }

## CORS headers
map $http_origin $cors_origin {
        default "";
        ~*.example.com$ "$http_origin";
    }

## Admin location http auth
geo $authentication {
    default "Authentication required";
    127.0.0.1 "off";
    1.2.3.4 "off";
}
    
## GEOIP routing
#map $geoip_country_code $geospatial {
#        default example.com;
#        RU      example.com/shipping.html;
#        US      us.example.com;
#        AS      as.example.com;
#}

# microcache
map $request_uri $no_cache {
	default 1;
	~/searchautocomplete/ajax/get/		0;
	~/catalogsearch/ajax/suggest/		0;
	~/search/ajax/suggest/			0;
}

## Multi shop code configuration
map $http_host $MAGE_RUN_CODE {
hostnames;
	  .domain1.co.uk base;
	  .domain2.com base_en;
}

map $http_host $MAGE_RUN_TYPE {
hostnames;
	  .domain1.co.uk website;
	  .domain2.com store;
}
    
## Map HSTS header
map $scheme $hsts_header { https  "max-age=31556926; includeSubDomains; preload"; }
    
## Map bad user agents
map $http_user_agent $bad_client {
    default 0;
  ~*(360Spider)  1;
  ~*(Aboundex|aiHitBot|AhrefsBot|AspiegelBot) 1;
  ~*(betaBot|BigBozz|BlackWidow|Bolt|BLEXBot|BUbiNG) 1;
  ~*(CazoodleBot|cispa|CPython|CCBot|ChinaClaw|Cliqzbot|coccocbot|Curious|CRAZYWEBCRAWLER|Custo) 1;
  ~*(Daumoa|Default|DeuSu|DIIbot|DISCo|discobot|DoCoMo|DuckDuckGo) 1;
  ~*(EasouSpider|eCatch|ecxi|EirGrabber|EmailCollector|EmailSiphon|EmailWolf|ExtractorPro|Exabot|Exploratodo|EyeNetIE) 1;
  ~*(FatBot|FlashGet|Findxbot) 1;
  ~*(GetRight|GetWeb!|GigablastOpenSource|Gigabot|gimme60bot|Go!Zilla|Go-Ahead-Got-It|Go.*package.*|GrabNet|Grafula|GT::WWW|GuzzleHttp) 1;
  ~*(heritrix|HaosouSpider|HMView|HTTP::Lite|HTTrack) 1;
  ~*(ia_archiver|IDBot|id-search|id-search.org|InterGET|InternetSeer.com|IRLbot) 1;
  ~*(JetCar) 1;
  ~*(larbin|LeechFTP|Lightspeedsystems|litemage_walker|Link|LinksManager.com|Lipperhey|LinkpadBot|linkwalker|lwp-trivial|ltx71) 1;
  ~*(Maxthon$|Mail.RU_Bot|meanpathbot|MegaIndex.ru|MFC_Tear_Sample|microsoft.url|Microsoft-IIS|Microsoft.*Office|Mozilla.*Indy|Mozilla.*NEWT|MJ12bot|MSFrontPage) 1;
  ~*(Navroad|NearSite|NetAnts|NetLyzer.*FastProbe|NetSpider|NetZIP|Nutch) 1;
  ~*(Octopus) 1;
  ~*(PageGrabber|panscient.com|pavuk|PECL::HTTP|PeoplePal|pcBrowser|Pi-Monster|PHPCrawl|PleaseCrawl|psbot|prijsbest) 1;
  ~*(Qwantify) 1;
  ~*(RealDownload|ReGet|RedesScrapy|Rippers|RocketCrawler) 1;
  ~*(SBIder|Scrapy|ScreenerBot|SEOprofiler|Screaming.*Spider|SeaMonkey|SeznamBot|SemrushBot|sitecheck.internetseer.com|SiteSnagger) 1;
  ~*(SmartDownload|Snoopy|SputnikBot|Steeler|SuperBot|SuperHTTP|Surfbot|sqlmap) 1;
  ~*(tAkeOut|Teleport|Toata|TwengaBot|Typhoeus) 1;
  ~*(URI::Fetch|User-Agent|UserAgent) 1;
  ~*(voltron|Vagabondo|VoidEYE|Visbot) 1;
  ~*(webalta|WebAuto|[Ww]eb[Bb]andit|WebCollage|WebCopier|WebFetch|WebLeacher|WebReaper|WebSauger|WebStripper|WebWhacker|WhatsApp) 1;
  ~*(WebZIP|Widow|Wotbox|WWW-Mechanize|WWWOFFLE) 1;
  ~*(XoviBot) 1;
  ~*(zermelo|Zeus|Zeus.*Webster|zgrab|ZyBorg) 1;
}

domain2-maps.conf

## Map php-fpm pass route
map $http_host$request_uri $MAGE_PHP_ROUTE {
    default unix:/var/run/php7.2-fpm-xxxxx.sock; # default php-fpm
}

    ## Map files to exclude from access log
#    map $request $writelog {
#                default   1;
#                ~*\.woff2 0;
#                ~*\.jpg   0;
#                ~*\.png   0;
#                ~*\.gif   0;
#                ~*\.css   0;
#                ~*\.webp  0;
#                ~*\.js    0;
#        }

## map query parameter to magento profiler parameter
map $query_string $MAGE_PROFILER {
  ~DEVELOPMENT=Q9ARzXbrwI html;
}

## Filter API access
map $request_uri $api_access {
            default 0;
        ~/(.*)/V1/customers(?!/me)              1;
	~/(.*)/V1/customers/password            1;
        ~/(.*)/V1/customers/resetPassword       1;
        ~/(.*)/V1/customers/isEmailAvailable    1;
        ~/(.*)/V1/guest-carts/                  1;
        ~/(.*)/V1/integration/                  1;
        ~/(.*)/V1/search                        1;
    }

## CORS headers
map $http_origin $cors_origin {
        default "";
        ~*.example.com$ "$http_origin";
    }

## Admin location http auth
geo $authentication {
    default "Authentication required";
    127.0.0.1 "off";
    1.2.3.4 "off";
}
    
## GEOIP routing
#map $geoip_country_code $geospatial {
#        default example.com;
#        RU      example.com/shipping.html;
#        US      us.example.com;
#        AS      as.example.com;
#}

# microcache
map $request_uri $no_cache {
	default 1;
	~/searchautocomplete/ajax/get/		0;
	~/catalogsearch/ajax/suggest/		0;
	~/search/ajax/suggest/			0;
}

## Multi shop code configuration
map $http_host $MAGE_RUN_CODE {
hostnames;
	  .xxxxxx.co.uk base;
	  .xxxxxxx.com base_en;
}

map $http_host $MAGE_RUN_TYPE {
hostnames;
	  .xxxxxxx.co.uk website;
	  .xxxxxxx.com store;
}
    
## Map HSTS header
map $scheme $hsts_header { https  "max-age=31556926; includeSubDomains; preload"; }
    
## Map bad user agents
map $http_user_agent $bad_client {
    default 0;
  ~*(360Spider)  1;
  ~*(Aboundex|aiHitBot|AhrefsBot|AspiegelBot) 1;
  ~*(betaBot|BigBozz|BlackWidow|Bolt|BLEXBot|BUbiNG) 1;
  ~*(CazoodleBot|cispa|CPython|CCBot|ChinaClaw|Cliqzbot|coccocbot|Curious|CRAZYWEBCRAWLER|Custo) 1;
  ~*(Daumoa|Default|DeuSu|DIIbot|DISCo|discobot|DoCoMo|DuckDuckGo) 1;
  ~*(EasouSpider|eCatch|ecxi|EirGrabber|EmailCollector|EmailSiphon|EmailWolf|ExtractorPro|Exabot|Exploratodo|EyeNetIE) 1;
  ~*(FatBot|FlashGet|Findxbot) 1;
  ~*(GetRight|GetWeb!|GigablastOpenSource|Gigabot|gimme60bot|Go!Zilla|Go-Ahead-Got-It|Go.*package.*|GrabNet|Grafula|GT::WWW|GuzzleHttp) 1;
  ~*(heritrix|HaosouSpider|HMView|HTTP::Lite|HTTrack) 1;
  ~*(ia_archiver|IDBot|id-search|id-search.org|InterGET|InternetSeer.com|IRLbot) 1;
  ~*(JetCar) 1;
  ~*(larbin|LeechFTP|Lightspeedsystems|litemage_walker|Link|LinksManager.com|Lipperhey|LinkpadBot|linkwalker|lwp-trivial|ltx71) 1;
  ~*(Maxthon$|Mail.RU_Bot|meanpathbot|MegaIndex.ru|MFC_Tear_Sample|microsoft.url|Microsoft-IIS|Microsoft.*Office|Mozilla.*Indy|Mozilla.*NEWT|MJ12bot|MSFrontPage) 1;
  ~*(Navroad|NearSite|NetAnts|NetLyzer.*FastProbe|NetSpider|NetZIP|Nutch) 1;
  ~*(Octopus) 1;
  ~*(PageGrabber|panscient.com|pavuk|PECL::HTTP|PeoplePal|pcBrowser|Pi-Monster|PHPCrawl|PleaseCrawl|psbot|prijsbest) 1;
  ~*(Qwantify) 1;
  ~*(RealDownload|ReGet|RedesScrapy|Rippers|RocketCrawler) 1;
  ~*(SBIder|Scrapy|ScreenerBot|SEOprofiler|Screaming.*Spider|SeaMonkey|SeznamBot|SemrushBot|sitecheck.internetseer.com|SiteSnagger) 1;
  ~*(SmartDownload|Snoopy|SputnikBot|Steeler|SuperBot|SuperHTTP|Surfbot|sqlmap) 1;
  ~*(tAkeOut|Teleport|Toata|TwengaBot|Typhoeus) 1;
  ~*(URI::Fetch|User-Agent|UserAgent) 1;
  ~*(voltron|Vagabondo|VoidEYE|Visbot) 1;
  ~*(webalta|WebAuto|[Ww]eb[Bb]andit|WebCollage|WebCopier|WebFetch|WebLeacher|WebReaper|WebSauger|WebStripper|WebWhacker|WhatsApp) 1;
  ~*(WebZIP|Widow|Wotbox|WWW-Mechanize|WWWOFFLE) 1;
  ~*(XoviBot) 1;
  ~*(zermelo|Zeus|Zeus.*Webster|zgrab|ZyBorg) 1;
}
@magenx
Copy link
Owner

magenx commented Apr 6, 2020

why do you need 2 map files?
you have single map variable

@IbrahimS2
Copy link
Author

@magenx Well, having multiple Magento instances with multiple domains and multiple PHP-FPM pools, we wanted to keep it neat, although from what we discovered the maps variables are unique, meaning I cannot use the same one even in a separate file, etc... it still mixes and very inconsistent.

Right, we had to rename the variables, still, I am considering using the same map file the way it should be instead of separating it all together, yes not very neat although it is the only way to get it working with one map file.

@magenx magenx closed this as completed Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants