W trakcie analizy

NodeJS App + Domain

neet_jn 4 lat temu • zaktualizowano 4 lat temu 22
I'm new to the whole MEAN stack, even more so to Ajenti ( which I love by the way ). I have all the plugins necessary to run my application running, and the forwarding to my domain seems to be working flawlessly. The only issue standing is my Node App runs on port 3000 - I'm playing around with KeystoneJS - and when I try and request my domain I'm throwing with a NGINX error ( 502 Bad Gateway ). This happens of course because there is no index/route document, and this can also easily be fixed by redirecting my application to port 80 -- which I cannot do because I'm planning on running several node apps.

The problem is, is that I'm either misunderstanding Ajenti's usage of NGINX or I need to override and redirect to port 3000. You see, I believed that just this would naturally get the job done as shown in the keystone tutorial found in the knowledgebase,

Though it does not sadly.
Note I can access my node app by visting www.mydomain.com:3000
W trakcie analizy
Does this mean Ajenti's running your Node app (as intended) or you used forever/supervisor/etc for that?
*Updated* Checked the generated nginx config -- should be sending requests to port 3000, but it's not?
Also, make sure that check /var/log/nginx/website.error.log for more info.
Thank you for replying so quickly, and I apologize for replying so late - I just got out of work. As for your first question, yes, Ajenti is running my application as intended ( I have forever installed for debugging, but it's not in use ).

Everything's working fine, but when I access my domain associated with my app, it just throws me a NGINX 502 error ( Bad Gateway ). That being stated, if I try and request my domain with the port my app is being hosted on ( 3000 ), I can access my node application without a hitch.

Regarding my error logs, they're completely empty.

It's not really much of an error, more of a configuration type issue.
Could it be that Ajenti has misconfigured your NGINX? Check with nginx -t.
If you see a 502, there has to be an error message in the logs. Either in /v/l/n/website.error.log, or in /v/l/n/error.log
Config is okay as also shown on Ajenti's CP, as for the error logs - they're empty.
That's impossible - check that error_log path is set in your /etc/nginx/conf.d/website.conf. If it's there, and NGINX config test succeeds, and you see an error page - error info should be in the log.
Error logs are specified correctly, I've tried viewing them via nano and the Ajenti CP -- but they're completely empty, including the access log. Just in case I even chmoded the files and triggered the error again, no luck.
Are you 100% sure that you're actually accessing your server when seeing the 502? No caching proxies, nothing?
I'm being thrown a NGINX error -- that much being stated I'm almost certain. The issue standing is that my domain is not pointing to my Node app's port, therefor I'm not sure where it's pointing @ my server. Though, as explained prior, if I pop :3000 onto my domain and physically try to access this port, I'm directed to my node app without any problems.
Could you post the domain name?
Try to tail -f all available logs in /var/log/nginx while accessing the website, in case NGINX is logging into a wrong file.
Sorry for the late reply, I was at work. As for restarting NGINX, I've tried this several times, I've restarted the server, etc. etc etc.

The issue honestly doesn't make sense to me, as the NGINX configuration should work.
I'm starting to believe it may be a problem with KeystoneJS. I'll look more into this tomorrow and post my results.
No luck, if it's not too much trouble, could you try setting up a node site using the latest version of Keystone on Ajenti-V w/ NGINX and report your results? I don't know why port 80 isn't proxying to 3000, it makes absolutely no sense.
For whatever reason ( may have been the chmod ), my error logs are populated with messages. The recurring theme seems to be,
-time- [crit] 6741#0: * connect() to failed (13: Permission denied) while connecting to upstream, client: -client ip-, server: $
Chown'd the www-data group/user to my website directory, now getting :
-time- [crit] 7080#0: * connect() to failed (13: Permission denied) while connecting to upstream, client: 73.xx.xxx.xxx, server: n
eet.ml, request: "GET / HTTP/1.1", upstream: "", host: "neet.ml"

THIS. This is SELinux denying connection to NGINX.
Got it working! Thanks for the help,

@Anyone having the same problem,
  1. chown www-data:www-data (group/user) to your website directory.
  2. Install policycoreutils-python from epel's repo.
  3. Run,

semodule -i mynginx.pp
In more simplified context, Ajenti is running my node app flawlessly, NGINX is proxying to my domain no problem, but my app isn't accessible on port 80 of my domain.

So I have to physically request the port my app is running on, on my domain, to get the node app.

* ps * disregard my original statement about the index file