Keep getting 404 on some URLs - python-3.x

Having followed the guide to setup django, postgres and nginx in digitalocean, am get different results for different urls.
Am using ubuntu 20 and python 3.10
<IP>:8000 => is working perfectly well
<IP> => 404 Not Found
<https://DomainName> => Showing the html page but Not showing the static files
<https://www.DomainName> => 404 Not Found
Where am I messing up??

Well unless you use web standards which ports are 443 for https and 80 for http you need to manually specify the port your service is located.

Related

need help on nginx configuration for nodejs api

my node api starts on port 1337 and works fine. if I browse localhost:1337 my api return nothing and if I browse localhost:1337/products my api actually works fine and return my products list as Json.
now service nginx installed and configured well to reverse-proxy of localhost:1337 to localhost
so after opening localhost it somehow works and says nothing as before but if I try browsing localhost/products again says nothing
and don't care about products.
I just have found the issue.
in nginx default configuration removed everything in section location /api/ just copy proxy_pass http://localhost:1337/; lonely. and it works correctly.

How to run express app on port 80 without sudo access

I am using the express framework for nodejs on a Dreamhost VPS and I want to run my server on port 80 but all of the answers I've seen require sudo/root access but on a Dreamhost VPS I am not given this permission. I can't edit any of the Apache files. The only thing I am able to do is create a .htaccess file. How can I achieve this?
You can try to run Node on a different port (greater than 1024, since those of 1023 or lower require root) and just proxy the requests through Apache by adding something like this to your .htaccess file:
RewriteEngine On
RewriteRule ^/(.*)$ http://127.0.0.1:8080/$1 [P,L]
(In this example Node would be running on port 8080).
For anyone who comes across this and has Dreamhost, the solution I came up with was creating a proxy. In the Dreamhost panel there is an option to create a proxy for a domain that you can then direct to go to any port for that domain and I simply made the proxy go to port 3000 and then my node server ran on port 3000.
#Frxstrem's answer also works but it failed to work when I shared a link and is kind of a hacky solution.

Running Node App on Shared Hosting (It's almost working)

I've managed to get Node and NPM installed on my shared hosting account with Namecheap by following this answer. It all seems to be working, I can launch my app and it stays launched, but the subdomain which points to app's root route just shows up the folder of the domain.
I've tried going to myaddress.com/subdomain:8080 but I get a server error plus a 404. I've also tried changing Node's listening port from 8080 to 80, but on 80 I get an error:
Error: listen EACCES 0.0.0.0:80
So that means I don't have rights to port 80. How can I get clients to connect port 8080?
This is the part that shared hosting has a problem with, they wont open any ports for you. This is exactly where your workaround needs to be centered. Im currently looking for solutions to either use php to serve a node
see here https://www.npmjs.com/package/node-php-server
and here How to host a Node.Js application in shared hosting
or just configuring express to use somehow port 80.
These would be your best options.

Website on Ajenti V with Node.JS content always throw 404

I install AjentiV to manage my website. Now I have an webapp on NodeJS and want to use with AjentiV. I follow a simple tutorial Setting up a Node.js website with Ajenti V (Keystone example) .
I config the Content of website to Node.JS, provide the script and config port 8080. I use port 8080 for the Node app, there are no error but I try the webapp always throw 404 - Not found result, in both port 80 and 8080.
Has anyone met this problem before? How can I make it works?
Thank you in advance! :)
Sorry, my bad. There is no problem with AjentiV and Node.JS content. The problem itself is the our webapp always throw 404 due to my fault config.

403 Forbidden after successfully installing Ghost

I have been spending days figuring out how to install the viral Ghost platform, and experienced numerous errors. Luckily, I have managed to install it - Ghost gives me a positive Ghost is running... message in SSH after I've done npm start --production. However, when I browse to my website - http://nick-s.se - Apache displays its default page and when I go to the ghost login area - /ghost, the site returns a 403 Forbidden.
P.S. I have specifically installed Ghost on a different port than the one Apache is running on. I don't know what's going on...
Update - I have found out that I can access my Ghost installation by adding the port number 2368 which I've configured in the config.js. Now, however my problem is - how can I run Ghost without using such ports?...
tell your browser you want to connect to the port Ghost is running on: http://nick-s.se:2368
So a few things, based on visiting:
1) It seems Apache isn't proxying the request onward to Ghost. Are you sure that you've configured it properly?
2) It also looks like Apache doesn't have access to the directory that you set as root. This shouldn't be necessary anyway if proxying is set up correctly, but could become an issue later if you wanted to use apache to serve things like the static assets.
If you are open to nginx instead of Apache, I have written a how to on this: link. You can skip the section on configuring Nginx. Otherwise, still might be useful if you figure out the conversion of rules from Nginx to Apache.
If you don't have any other sites running on your VPS you can just turn apache off and not have to deal with apache proxying the request to port 2368 and have Ghost run on port 80. If your VPS is running CentOS you can check out this how to on disabling apache and running Ghost on port 80.

Resources