1

I have a application in a vps server that have the backend in node.js and the frontend in Angular;

I restart the nginx and something problems starts. My api don't work more in https, only in http (before i can make request in https);

When i access in browser the link of my application i receive a message from my backend, as if i'm making a get in this route, but before than i restart the nginx when i access this link my frontend shows the login page...

My angular dist files is in public_html and my node app is in /nodeapp;

This is my nginx conf:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log;
    error_log error.log warn;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
 server {
        listen 80;
        listen [::]:80 ipv6only=on;
        server_name knowhowexpressapp.com;
        location / {
    proxy_pass http://189.90.138.98:3333;
    proxy_http_version 1.1;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}

I try some things like:

pm2 restart server;
nginx -s reload
service nginx restart

but my frontend is still not showing when i try to access the page.

10
  • Do you have errors in console? Commented Feb 18, 2020 at 16:16
  • @Fmerco no, i don't have errors in any log or console Commented Feb 18, 2020 at 16:17
  • Please open network tab and check if there is an error there. thanks Commented Feb 18, 2020 at 16:20
  • If you are using a dynamic Ip like this... 189.90.138.98 probably it has changed. Don't not share personal information like this. Commented Feb 18, 2020 at 16:29
  • @Fmerco if you ping the domain, you get this ip as a return, i don't think this is a personal information Commented Feb 18, 2020 at 16:31

1 Answer 1

1
+50

As we have been able to deduce together, the configuration of nginx started a redirect towards the backend incorrectly.

Our solution was to not use nginx and expose the port we needed on the server so that the angular application could reach it.

Of course we could also use nginx in this regard and redirect only one path to a specific port.

Sign up to request clarification or add additional context in comments.

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.