Home > Software engineering >  Can't assign domain to Angular project on specific port with Nginx on ubuntu
Can't assign domain to Angular project on specific port with Nginx on ubuntu

Time:11-29

I have an Angular project that's using the port 4201. I built the project and configured nginx to deploy it.

When I access my server with the IP Address, and the specified port, everything works.

I would like to assign my domain name to this project, and I followed lots of tutorials, but it always shows the "Welcome to Nginx" page...

I'm lost.

Here is the configuration I put in /etc/nginx/sites-enabled :

server {
        listen 4201;
        listen [::]:4201;
        root /var/www/html/alienprods;
        index index.html index.htm;
   server_name alienprods.com www.alienprods.com

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

Do you have any idea ? Am I forgetting something ? Thanks in advance for your help !

CodePudding user response:

I finally found my issue. I didn't understand nginx well enough.

Here is my alienprods.conf file now :

server {
        listen 4201;
        listen [::]:4201;
        root /var/www/html/alienprods;
        index index.html index.htm;

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

server {
        listen 80;
        listen [::]:80;
        server_name alienprods.com www.alienprods.com;

   location / {
       proxy_pass http://*MY_IP_ADDRESS*:4201;
   }
}

  • Related