So here's my setup:
Digital Ocean 1gig droplet
Ubuntu 14.04x64
Dokku 1-click installer
MongoDB attached to Dokku via https://github.com/jeffutter/dokku-mongodb-plugin. Verified. I can connect to it via robomongo
domain registered in DNS records in my DigitalOcean dashboard (subdomain.mydomain.com)
website is accessible (verified via tailed app-access.log)
the basic meanjs app via their yo generator
only modified connection to mongodb server in Dokku.
push to Dokku is successful, no push errors
DigitalOcean swapfile create (1gig), no memory warnings according to dokku logs app
properly set Dokku env variables verified via dokku config app
properly set VHOST file to mydomain.com
My issue is everytime I visit the site, assets load (up until favicon.ico, along with /lib/bootstrap/dist/css/bootstrap.min.css and many others from that directory), but it stops there. The site doesn't load anything after that. The favicon shows up then nothing.
I checked the nginx logs, nothing. This is a practice website so I will be posting the nginx.conf:
server {
listen [::]:80;
listen 80;
server_name mean.ygamretuta.xyz ;
access_log /var/log/nginx/mean-access.log;
error_log /var/log/nginx/mean-error.log;
location / {
proxy_pass http://mean;
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-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
}
include /home/dokku/mean/nginx.conf.d/*.conf;
}
upstream mean {
server 172.17.0.62:3000;
}
I checked nginx logs, dokku logs, I got nothing. What could be wrong?
A little more googling and I found that I should issue a grunt build before I push my code to Dokku residing in Digital Ocean.
here's the discussion in meanjs issues:
https://github.com/meanjs/mean/issues/64
Related
I want to host a Nodejs API server to my digitalocean server where a WordPress application is already running using Nginx and PHP fpm
I followed the below link to set up the WordPress application and it's working fine now.
https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-web-server-and-reverse-proxy-for-apache-on-one-ubuntu-18-04-server
I wanted to set up Nodejs application inside the same server for demo purposes and I followed the digitalocean guide for setting up node js with a different config file and subdomain.
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04
My Nginx config for node application looks like this
server {
server_name sub.domain.com
location / {
proxy_pass http://localhost:6969;
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 have allowed port 6969 using ufw allow 6969.
I am able to access the Nodejs application using sub.domain.com:6969 but sub.domain.com gives me a 404 error. (404 Not Found nginx/1.18.0 (Ubuntu))
I want to access Nodejs application directly without a port number. I have checked Nginx logs and there are no errors, and configures is gives success in nginx -t
Please give me some suggestions to debug and fix this issue. I don't have much knowledge in Nginx configuration. I was just following tutorials from Digitalocean to configure the WordPress and node application.
Thanks in Advance
You are missing the port
server {
server_name sub.domain.com;
listen: 80;
location / {
proxy_pass http://localhost:6969;
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 would like to have a more stable deployment of a sails 1 app on an AWS ubuntu server using nginx as reverse proxy.
Goal:
To have a non-version-dependent deployment of our app.
In particular:
We have an app on an AWS server.
App details include:
mobile focused
websockets enabled
reverse proxy with nginx
app persisting with pm2
Deployment details include
AWS ubuntu 18.04 LTS
mysql 8.x database
sails 1.2.4
nginx 1.14.0
node 8.4.0
The issue:
I was only able to get the reverse proxy working with the above versions of sails, nginx, and node. Any other combination resulted in a 403 error from the app server. Postman GET requests to the server when the app is served directly return a "sails.sid" cookie. However, when the app is served through any other reverse proxy software combination, no "sails.sid" cookie comes back in the GET header. I got the same no cookie GET request with apache2 reverse proxy.
When I hit the app directly (not through the reverse proxy) the cookies returned fine.
What I have tried
different versions of node, sails1, nginx, apache2
node versions > 10.22.0 cause the error
there is a known deprecation in node > 10.22.0 of the command
link to node deprecation
The http module OutgoingMessage.prototype._headers and OutgoingMessage.prototype._headerNames properties are deprecated.
This seems to break the nginx reverse proxy handling of headers from the sails app.
I have not seen a fix in nginx, and in particular nginx version 1.16.0 will break the headers.
other things I have tried
ownership and permissions (chmod, chown) are ok
apache2 reverse proxy: same problem as with nginx 1.16.0: no headers. I.E. the reverse proxy works, but the app returns a 403 code through the apache2 reverse proxy.
various permutations of versioning: sails, nginx, node
things I might try
Somewehere in the node-modules of sails, there may lurk header code depending on this old syntax. This could possibly be patched with a replace new-for-old on the appropriate statements. Just a thought.
What I would like:
Show me how to get this app working, i.e. get all the headers back from a vanilla Postman GET request, in a way that does not depend on these specific versions of sails, nginx, and node.
If I am missing something glaringly obvious, even better.
I am using a similar setup with node 11.15.0 and it works.
What is your nginx configuration?
Here is the server block code I tried to put in the comments. Remeber that you have to symlink it to the /etc/nginx/sites-enabled folder as well. This works for straight HTTP requests. Note that your app will only see the client "127.0.0.1". If you want to get the IP addresses from your clients out in the wild, you need to get them from the nginx reverse proxy server itself.
server {
listen 80;
server_name yourDomain.com ;
location / {
proxy_pass "http://127.0.0.1:1337";
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header Port $server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass_request_headers on;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /socket.io/ {
proxy_pass "http://127.0.0.1:1337/socket.io/";
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header Port $server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass_request_headers on;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
I wrote some nodejs services in my ubuntu local.Now I want to deploy my nodejs services into nginx server in my seperate VM.I set up the nginx in my virtual machine.How can I pull my nodejs services to nginx server and how to connect these api's through postman. I getting confusion at nginx config file.
You should setup a reverse proxy with nginx to redirect the traffic to you node application. Install node on your VM, copy your application and install all the dependencies using npm install. Afterwards, you should start the node application using node index.js where index.js is the entry point of your application. You could also use a process manager such as pm2 to start the application. Then, you have to setup the reverse proxy with nginx which is redirecting the traffic to the port of your application. (In your sample code 3000). The application should now be available on the IP of your VM. Below you find a minimal example configuration for nginx.
server {
listen 80;
server_name domain.com;
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;
}
}
I created a skeleton app with jhipster and added some entitles with import-jdl. Now I'm trying to run the dev profile and it hosts it on localhost:8080, which is fine. But I want to proxy it to the public Internet through nginx and put it behind SSL.
Now if I were using Tomcat as an app server, I could set the proxyHost property on the Connector to tell the app server what its public-facing URL is so it generates URLs for the client properly.
But I don't know what app server jhipster uses for the dev profile or how to configure it.
There are a few ways you can go to solve your problem,
The most simplest one is to reverse proxy using nginx, like this:
server {
listen [::]:80;
listen 80;
server_name your-domain.com;
access_log /var/log/nginx/your-app-access.log;
error_log /var/log/nginx/your-app-error.log;
return 301 https://$host:443$request_uri;
}
server {
listen [::]:443 ssl;
listen 443 ssl;
server_name your-domain.com;
access_log /var/log/nginx/your-app-access.log;
error_log /var/log/nginx/your-app-error.log;
ssl_certificate /path/to/ssl/server.crt;
ssl_certificate_key /path/to/ssl/server.key;
keepalive_timeout 70;
add_header Alternate-Protocol 443:npn-spdy/2;
location / {
proxy_pass http://jhipster;
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-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
}
}
upstream jhipster {
server 127.0.0.1:8080;
}
which should work on every nginx.
This expects your app running at port 8080 at localhost, what is the case when you start it locally. This furthermore requires you to install java and more stuff on your server.
A better way is to use the docker option to create docker images. There are a lot of ways to handle with docker images, like public repository as DockerHub as well as private solutions, like GitLab Container registry. At least you can do a trick by serving the registry docker image at some server with ssl, to use this for private registry.
Then you can at least deploy your app to the same nginx configuration as written above, directing traffic to a running docker container. With this, you only need a arbitrary linux distribution with docker and nginx running.
To gain the power of CI/CD systems, you can deploy these images to complex systems like kubernetes, but also to docker swarm (+ Docker Shipyard), or to smaller and easier to setup solutions like Deis or Dokku. You can read this article, which guides you through a setup of GitLab + GitLab CI + Registry + Dokku, where you can deploy your JHipster application using git push origin master
note: I suggest not to use the dev profile in production. To keep update with your application logs, consider specific logback configuration or solutions as JHipster Console (ELK Stack)
I'm learning Keystone, trying to deploy onto Digital Ocean. I can clone and make Keystone runs like this:
------------------------------------------------
KeystoneJS Started:
Example Site is ready on port 3000
------------------------------------------------
I followed the book, setup nginx like this
server {
listen 80;
server_name examplesite.com;
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;
}
}
The domain's DNS is pointed to Digital Ocean, and it worked fine with my old WordPress version. I've just destroyed the droplet, and reinstalled everything, so this is not domain's problem.
Despite I did anything, I still can not reach the Keystone:
This site can’t be reached
examplesite.com took too long to respond.
Some information:
Node: v4.5.0
npm: v3.10.6
Ubuntu: 16.04
Please help.