I am doing something wrong configuring my ubuntu server
My browser displays : 403 Forbidden nginx/1.10.3 (Ubuntu)
And if i run :
tail -f /var/log/nginx/error.log
i get:
".../root/curlist/index.js" is forbidden (13: Permission denied)..."
This is what i have in sites-enabled:
What is the problem?
ps after editing the sites enabled
if i run:
systemctl status nginx.service
i get :
However if i run :
tail -f /var/log/nginx/error.log
i get:
connect() failed (111: Connection refused) while connecting to upstream
You should not directly run index.js in nginx.
Instead, run index.js with node.js in the background, then setup nginx to forward to its listening port.
e.g.
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;
}
Read an tutorial of node.js + nginx configuration here.
Related
I'm deploying my project, I had no problem until i decided to buy a domain for my digital ocean droplet i added the records from my namecheap domain to my droplet i was working on it then suddenly when i want access to myproject/api it's now showing 502 errors i'll give you all the informations so maybe you can help me with it
1 ) mongoDB atlas status : All good ; i even tried " npm start " to see if DB can't connect but it connects perfectly fine. I refreshed in .env the connecting string, it stills connect with no problems.
2 ) Nginx error.log shows this information i don't really understand, i guess it's the key point :
86 connect() failed (111: Connection refused) while connecting to upstream, client: 164.92.206.160, server: _, request: "GET /api/category/cinema HTTP/1.1", upstream: "http://[::1]:8000/api
3 ) The front is perfectly showing himself on my project domain url it starts showing 502 error when i click something using my DB/server.
4 ) i rebuilded and restarted front & back + nginx multiple times
5 ) i updated endpoints and .env variables to match with my fresh domain and it works, only the API side is breaking
6 ) nginx conf file :
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
server_name _;
location /api {
proxy_pass http://localhost:8000;
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 / {
proxy_pass http://localhost: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;
}
I tried barely everything and it's still not working as it was used to work.
I've dealt with this error in the nginx error log for the past few hours.
*2 connect() failed (111: Connection refused) while connecting to upstream, client: my ip, server: my domain, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:3000/", host: "my domain"
I'm currently trying to deploy a next.js app with nginx using engintron for CPanel as well as pm2.
default.conf
server {
listen [::]:80 default_server ipv6only=off;
server_name my domain domain-ip;
# deny all; # DO NOT REMOVE OR CHANGE THIS LINE - Used when Engintron is disabled to block Nginx from becoming an open proxy
# Set the port for HTTP proxying
set $PROXY_TO_PORT 8080;
include common_http.conf;
common_http.conf
location / {
proxy_pass http://127.0.0.1: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;
}
There aren't any errors on pm2's front, and sudo nginx -t works just fine, so I'm confused on what exactly the issue is.
Any sort of help is appreciated, have a good rest of your day :)
Fixed the issue, for some reason my pm2 wasn't working properly, after a clean reinstall I got this issue fixed, but now I've got a 404 not found for my index file, the fun life of being a developer lol
We have developed a testing application in Twilio Sandbox and it is running fine in Heroku server. But when we are trying to put it in Linux (centos 8.1.1911) server, getting 404 error.
conf file in Linux server:
location /myapp/ {
proxy_pass http://13.71.23.139:3020/;
proxy_ssl_server_name on;
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;
error:
*212 connect() failed (111: Connection refused) while connecting to upstream
Any suggestions?
I am new to Linux and read several articles to host asp.net core we applications on the Linux server. I have installed NGINX and modified /etc/nginx/sites-available/default. I ran this following command and it shows application started. I tried to check my application on the browser(using IP). It shows "502 Bad Gateway" error. I checked error log(/var/log/nginx/reverse_error.log) to see any errors. But it doesn't provide any relevant errors except http headers information. How to troubleshoot more on this issue?
$ sudo dotnet testapp.dll
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/root/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
Hosting environment: Production
Content root path: /var/www/testapp
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
/etc/nginxsites-available/default
server {
listen 80; # [::]:80;
listen [::]:80 ipv6only=on;
access_log /var/log/nginx/reverse_access.log;
error_log /var/log/nginx/reverse_error.log debug;
#rewrite_log on;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
I am attempting to deploy a meteor app to my production server, running on Ununtu 14.04 and I am getting the following error in my log file (/var/log/nginx/error.log)
2014/12/02 16:03:38 [error] 19231#0: *4267 connect() failed (111: Connection refused) while connecting to upstream, client: 162.13.2.250, server: theserver.com, request: "GET /content/staticContent.json HTTP/1.1", upstream: "http://127.0.0.1:3000/content/staticContent.json", host: "theserver.com"
My app is fetching json content from 5 files and these are included as part of the project.
I have the following nginx configuration file. I am running nginx 1.6.2.
I should also note that visiting http://theserver.com/content/staticContent.json loads the content in my browser.
I have also run 'wget http://127.0.0.1:3000/content/staticContent.json' from the command line when logged into my production server and I can fetch the content.
server_tokens off;
upstream anna {
server 127.0.0.1:3000;
}
# HTTP
server {
listen 80;
#server_name *.theserver.com;
server_name theserver.com;
location / {
proxy_pass http://anna;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-NginX-Proxy true;
proxy_redirect off;
}
}
I also have the following upstart configuration file to run my Meteor App in a node fibre
description "Meteor.js (NodeJS) application for theserver.com"
author "Me <me#theserver.com>"
start on started mongodb and runlevel [2345]
stop on shutdown
respawn
respawn limit 10 5
setuid anna
setgid anna
script
export PATH=/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export NODE_PATH=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript
export PWD=/home/anna
export HOME=/home/anna
export BIND_IP=127.0.0.1
export PORT=3000
export HTTP_FORWARDED_COUNT=1
export MONGO_URL=mongodb://localhost:27017/anna
export ROOT_URL=http://theserver.com/
exec node /home/anna/bundle/main.js >> /home/anna/anna.log
end script
My process for deployment is as follows:
On my local machine I run 'meteor build .' and then scp that to my production server to the above home directory
I then untar the .tar.gz file, cd into bundle/programs/server and run 'npm install'
Finally, when logged in as 'anna' with sudo rights, I run 'sudo start anna' given the above upstart script
On checking the generated log file, I see the generated html telling me there is a 502 bad gateway error.
When I go to the URL for the live website, I can see the loading icon I have put in place. This is the Meteor loading template I have put in place and I have configured IronRouter to use this as a loading template while it is waiting for the subscription to my collection to be filled, but this never happens because my server side mongodb instance never gets populated, for the reasons above.
Can anyone see anything unusual in the above that might be causing this 502 bad gateway error?
Running netstat -ln indicates to me that node.js is running, see below:
tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN
Thanks
Have you tried using meteor-up ? It handles the bundling and upstart config for you.
The suggested nginx config for meteor-up is below, it looks pretty similar to yours (taken from Using Meteor Up with NginX vhosts).
/etc/nginx/sites-enabled/mycustomappname.com.conf
server {
listen *:80;
server_name mycustomappname.com;
access_log /var/log/nginx/app.dev.access.log;
error_log /var/log/nginx/app.dev.error.log;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-For $remote_addr;
}
}