Reputation: 1055
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.
Upvotes: 1
Views: 232
Reputation: 1206
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.
Upvotes: 1