0

I want to do nginx setup for handing two project with same domain.

Example domain: example.com

  • Angular project should run with example.com
  • magento2 project should run with example.com/shop

I tried the code below, but its not working.

location /shop {
    alias /var/www/www.example.com/shop/;
    index index.html;
    try_files $uri $uri/
    autoindex on;
}

Can please someone help me to do this.

2 Answers 2

1

You should use official NGINX configuration sample as provided here.

Naturally, you will prefix all the Magento 2 locations with /shop/, for your specific case.

So you will end up with this kind of config:

server {
    listen       80;
    server_name  example.com;

    location / {
        root /path/to/your/generated/angular/resources;
        try_files $uri$args $uri$args/ /index.html;
    }
    # Magento 2 directives start here...
    location ~* ^/shop/setup($|/) {
        # ...
    }
    # The rest of Magento 2 directives...
}
Sign up to request clarification or add additional context in comments.

Comments

0

You can start with the following config to serve your Applications:

server {
    listen       80;
    server_name  example.com;

    location / {
        root /path/to/your/generated/angular/resources;
        try_files $uri$args $uri$args/ /index.html;
    }

    location /shop {
        root /path/to/shop/;
        index index.html;
        try_files $uri $uri/;
    }
}

I'm not 100% sure if the shop route will work. Maybe you need to configure php to serve it. Therefore you can follow this official example.

If you want to serve also to www.example.com you can set server_name *.example.com (docs).

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.