My task is create landing page which sends emails with requisites for payment on submitting form.
So I have simple static frontend (index.html, css/, js/, img/) and express server which sends emails (server.js);
On my localhost I run the frontend on localhost:3000
and server.js on localhsot:3000
. After adding CORS headers everything started work fine, emails were successfully sent.
For production I've bought a VPS with ubuntu to deploy all this.
I've setup nginx so my frontend available on myDomainName.com. But when I run server.js it doesn't receive requests as it did on dev server. In the same time if I connect via ssh and type curl myDomainName.com:3000/
, I receive response 'Hi';
// server.js
// some code...
app.get('/' function (req, res) { res.status(200).end('Hi'); }
app.listen(3000, function () { console.log('Server listening on port 3000!'); })
// frontendFormHandler.js
// some code...
$.get('myDomainName.com:3000/', function(data){ console.log(data) })
How should I set up all this to make it work on same VPS, same domain, but on different ports? What is the right way to deploy those kind of small projects? Should I choose another instruments?
In most UNIX systems the firewall is configured to only allow traffic from other clients on ports 80
and 443
for HTTP and HTTPS, all other ports are blocked for security reasons.
To allow the ports (with ufw) use
$ (sudo) ufw allow 3000/tcp
$ (sudo) ufw allow 3000/udp
Or, for IPTables:
$ (sudo) iptables -I INPUT -p tcp --dport 3000 -j ACCEPT
$ (sudo) iptables -I INPUT -p udp --dport 3000 -j ACCEPT
to allow connections on TCP or UDP