1

I've been wondering lately whether having the backend for magento on a completely separated URL would be possible, as magento historically has real problems confusing frontend and backend cookies for people having to use both logins.

For me it's fine as i'm perfectly happy using incognito windows where needed and clearing cookies, but when general members of staff encounter cross-cookie pollination they don't always spot it as such.

Having the frontend on example.com and the backend on examplebackend.com/admin would potentially resolve this, but will probably create a number of other issues first.

has anyone done something similar in the past?

1 Answer 1

0

This nginx configuration could be a starting point for you:

# map domains to Magento website identifiers
map $http_host $MAGE_RUN_CODE {
    default '';
    frontend.loc base;
}

upstream fastcgi_backend {
  server unix:/sock/docker.sock;
}

server {
  listen 80;
  server_name _; # catch all
  set $MAGE_ROOT /var/www/html;
  set $MAGE_RUN_TYPE website;

  include /var/www/html/nginx[.]conf;
}

This basically maps different hostnames to different website or store view codes.

You can still reach the admin on both urls. If you would want to block the admin url for one specific host, you should be able to wrap the location deny instruction in an if statement like this:

if ($http_host ~* (frontend)) {
   location /admin {
    // ...
    Deny All;
    // ...
   }
}
2
  • we're using apache and varnish rather than nginx, but we have something similar for our multistore setup using the SetEnv MAGE_RUN_CODE and MAGE_RUN_TYPE directives in the vhosts to point to different parts of the frontend, but only the frontend gets website/store codes as far as i'm aware. Commented Oct 15, 2021 at 14:30
  • edit: looks like there are no MAGE_RUN_TYPES that can target backends, and if you set a vhost with an alternate name pointing to the same place it will direct you there, but won't stay on the new url, will just revert to the highest priority Commented Oct 15, 2021 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.