Host multiple meteor application on DigitalOcean - node.js

I need to run two meteor applications at the same Digital Ocean droplet. Following this tutorial I successfully get both apps to work on my-domain.com:3000 and my-domain-1.com:3001, but I can't get reversing proxy using Nginx done. Following the tutorial I came up with the following:
First app configuration file:
server {
listen 80;
server_name http://saveting.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Second app configuration:
server {
listen 80;
server_name http://downloadinstagramvideo.com;
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
EDIT1 :
The problem was that nginx has to be restarted before implementing changes. Works after using:
sudo service nginx start

The server_name directive should not include the scheme name, use:
server_name saveting.com;
and
server_name downloadinstagramvideo.com;

Related

nginx node 502 Bad Gateway nginx/1.18.0

I saw a lot of people ask this question but never answerd. I have a node applocation and Im deploying it using nginx. This occured when I try to deploy multiple sites on same instance. But now I have removed one. This is my config:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
the nginx error log:
I just freed the port 8080 and tried installing nginx and pm2 again and it worked.

Node.js is not working in Reactjs app - nginx

Locally everythings is working correct, now im trying to get the node working but i can't
It's my nginx config:
server {
listen 80;
server_name 54.38.184.210;
location /api/ {
proxy_pass http://54.38.184.210:8080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location / {
root /root/site/public;
try_files $uri /index.html;
}
}
http://54.38.184.210/
i run - npm run build, then i put all dist files into public, the static content is working, i can see whole website, but the backend is not working, im starting my server using "node index.js"
Maybe im doing something wrong, please help me!
Please try this,
server {
listen 443 ssl;
server_name 54.38.184.210;
ssl_certificate {your path to .crt file}/api.crt;
ssl_certificate_key {your path to .rsa file}/api.rsa;
location / {
proxy_pass 54.38.184.210:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
"service nginx restart" to restart your backend nginx

Nginx screen appering on first request to the domain

The first requests in the browser to this following API's are appering the Nginx screen.
Goeat Api GympointApi
Idk what is wrong on my proxy configuration
server {
listen 80;
server_name gympoint.lauradeveloper.com.br;
location / {
proxy_pass http://localhost:3333;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
server {
listen 80;
server_name goeat.lauradeveloper.com.br;
location / {
proxy_pass http://localhost:4000;
}
}
It's working completely fine but on the first request to the browser, shows this nginx screen. Looking my proxy configuration, does anyone know what i'm did wrong?
I kind solved this. I had to put these same options related to proxy on the other server config.

hosting nodejs applications using nginx in ec2 AWS

/etc/nginx/nginx.conf file
in http section, given the below informaiton.
include /etc/nginx/conf.d/*.conf;
/etc/nginx/conf.d/myapp.conf file content
server {
listen 80;
listen [::]:80;
server_name _;
index index.html index.htm;
location / {
proxy_pass 'http://XXXXX:3005/';
}
location /admin/ {
proxy_pass 'http://XXXX:3000/';
}
}
http://XXXX is redirecting to the main page.
http://xxxxx/admin/ is not redirecting. Instead it is throwing below errors in chrome console.
error image
The same site is working fine http://xxxx:3000 it is working fine. No issues.
Whatelse am I missing?
Note: OS is Amazon Linux & I have tested the same configuration with sample help world node js program & it is working fine.
Make sure that your routing is correct and that you have restarted nginx after configuration.
Try the following configuration:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://APP_PRIVATE_IP_ADDRESS:3005;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /admin {
proxy_pass http://APP_PRIVATE_IP_ADDRESS:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

Mutliple Node app with Nginx

I'd like to run multiple node app throught a Nginx server for the reverse proxy. I actually have something like that in my config file :
server {
listen 80;
server_name http://my.server.url;
location / {
root /absolute/path/to/index/;
index index.html;
}
location /foo/ {
proxy_pass http://127.0.0.1:3000; # here is an nodejs app runing
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
The problem : In my nodejs app, I receive url with the '/foo/' before.
I try to monkey arround with rewrite but honestly I'm confuse, so I'd like to get '/bar/' instead of '/foo/bar/', how should i proceed?
What you need is called rewrite in nginx
location /foo/ {
rewrite ^/foo(.*)$ /$1 last;
proxy_pass http://127.0.0.1:3000; # here is an nodejs app runing
}

Resources