0

I'm newbie with Nginx and server configurations. I'm trying to deploy a Wordpress web and Angular 2 webapp (each project in a different folder/path) using the same domain and configured by Nginx. For http://example.com i need the wordpress site to be loaded and for http://example.com/demo the Angular app.

After some research and tries, I can make the Angular app runs alone setting the path in the root part but when i change the Nginx config file to include the location block and root for the Wordpress, the web works but the Angular app cannot find the js and css files. Also, the Wordpress web has the contact and privacy policy pages which cannot be found (http://example.com/contact and http://example.com/privacy-policy).

The projects paths are:

/var/www/dashboard/dist/angularApp/
/var/www/wordpressWebsite

My current Nginx config file contains:

server {
    server_name example.com www.example.com;

    root /var/www/wordpressWebsite;
    index index.php index.html index.htm;

    location / {
          try_files $uri $uri/ /index.php;
    }

    location ~ \.php$ {
          include snippets/fastcgi-php.conf;
          fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location /demo {
          alias /var/www/dashboard/dist/angularApp/;

          try_files $uri $uri/ /index.html;
    }

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

Hope someone can help me with that, thank you so much in advance!

New contributor
Rubén is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1

0

You must log in to answer this question.

Browse other questions tagged .