We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
can not start NodeJS applications with SLL
can not start NodeJS applications with SLL
I can not run my application on Ubuntu VPS with VestaCP.
I started with pm2 my application on the server on port 3000.
Before that, I made some preparations:
1) Installed let's encrypt certificates
2) Applied force-https template so that ngnix redirects me from HTTP
VestaCP generated 2 ngnix configs - my-site.com.nginx.ssl.conf and my-site.com.nginx.conf
When I run my site on my-site.com - there is 403 error
The decision is quite easy - I should change to
Then restart nginx
But in this case, I have 500 error. And I really confused about setting...
These are configs:
Note that 10.223.41.249 is my server internal IP. I suppose given by Vesta.
My network activity is
Hope, this would help
There is also a config in my app. I'm not sure but I suspect this too
I started with pm2 my application on the server on port 3000.
Before that, I made some preparations:
1) Installed let's encrypt certificates
2) Applied force-https template so that ngnix redirects me from HTTP
VestaCP generated 2 ngnix configs - my-site.com.nginx.ssl.conf and my-site.com.nginx.conf
When I run my site on my-site.com - there is 403 error
The decision is quite easy - I should change
Code: Select all
proxy_pass https://10.223.41.249:8443;
Code: Select all
proxy_pass https://10.223.41.249:3000;
Code: Select all
service nginx restart
These are configs:
Note that 10.223.41.249 is my server internal IP. I suppose given by Vesta.
Code: Select all
# my-site.com.nginx.conf
server {
listen 10.223.41.249:80;
server_name my-site.come www.my-site.com;
location / {
rewrite ^(.*) https://my-site.com$1 permanent;
}
include /home/admin/conf/web/*nginx.my-site.com.conf_letsencrypt;
}
Code: Select all
# my-site.com.nginx.ssl.conf
server {
listen 10.223.41.249:443;
server_name my-site.com www.my-site.com;
ssl on;
ssl_certificate /home/admin/conf/web/ssl.my-site.com.pem;
ssl_certificate_key /home/admin/conf/web/ssl.my-site.com.key;
error_log /var/log/apache2/domains/my-site.com.error.log error;
location / {
proxy_pass https://10.223.41.249:3000;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|pdf|psd|ai|eot|e$
root /home/admin/web/my-site.com/public_html;
access_log /var/log/apache2/domains/my-site.log combined;
access_log /var/log/apache2/domains/my-site.site.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /error/ {
alias /home/admin/web/my-site.com/document_errors/;
}
location @fallback {
proxy_pass https://10.223.41.249:3000;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include /home/admin/conf/web/*nginx.my-site.com.conf_letsencrypt;
include /home/admin/conf/web/snginx.my-site.com.conf*;
}
Code: Select all
root@46:/home/admin/conf/web# sudo netstat -ltunp | grep 80
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 7804/mongod
tcp 0 0 10.223.41.249:80 0.0.0.0:* LISTEN 6225/nginx: master
tcp 0 0 10.223.41.249:8080 0.0.0.0:* LISTEN 2778/apache2
tcp 0 0 127.0.0.1:8081 0.0.0.0:* LISTEN 2778/apache2
tcp 0 0 0.0.0.0:8083 0.0.0.0:* LISTEN 26350/nginx: master
tcp 0 0 127.0.0.1:8084 0.0.0.0:* LISTEN 6225/nginx: master
root@46:/home/admin/conf/web# sudo netstat -ltunp | grep 443
tcp 0 0 10.223.41.249:443 0.0.0.0:* LISTEN 6225/nginx: master
tcp 0 0 10.223.41.249:8443 0.0.0.0:* LISTEN 2778/apache2
root@46:/home/admin/conf/web# sudo netstat -ltunp | grep 8443
tcp 0 0 10.223.41.249:8443 0.0.0.0:* LISTEN 2778/apache2
root@46:/home/admin/conf/web# sudo netstat -ltunp | grep 3000
tcp6 0 0 :::3000 :::* LISTEN 2146/node
root@46:/home/admin/conf/web#
There is also a config in my app. I'm not sure but I suspect this too
Code: Select all
module.exports = {
'process.env.BASE_URL': prod
? 'https://my-site.com'
: 'http://localhost:3000'
};
-
- Support team
- Posts: 1047
- Joined: Fri Mar 21, 2014 7:49 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: can not start NodeJS applications with SLL
Tell me, is this some kind of complete script or did you write it yourself? If this is a complete script, you need to see the documentation.
Re: can not start NodeJS applications with SLL
Thanks for reply.
The `complete script` - is it about the code of my app, or nginx config?
Nginx config I presented was just genegated from .tpl and .stpl files that are inside VestaCP bundle - i can not write it myself.
The `complete script` - is it about the code of my app, or nginx config?
Nginx config I presented was just genegated from .tpl and .stpl files that are inside VestaCP bundle - i can not write it myself.
-
- Support team
- Posts: 1047
- Joined: Fri Mar 21, 2014 7:49 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: can not start NodeJS applications with SLL
The app uses next.js framework. But I almost shure that it doesn't affect to nginx because it works as usual node.js application.
I just run express server from pm2 command running on 3000 port.
I just run express server from pm2 command running on 3000 port.
-
- Support team
- Posts: 1047
- Joined: Fri Mar 21, 2014 7:49 am
- Contact:
- Os: CentOS 6x
- Web: apache + nginx
Re: can not start NodeJS applications with SLL
Documetation tells that I should remove try_files and set some headers... I also removed file types.
Please, check If my nginx config is correct. I'm totally new to all that stuff.
Server returns 500 in this way too -(...
and are made...
Please, check If my nginx config is correct. I'm totally new to all that stuff.
Server returns 500 in this way too -(...
Code: Select all
server {
listen 10.223.41.249:443 ssl;
server_name my.site www.my.site;
# ssl on;
ssl_certificate /home/admin/conf/web/ssl.my.site.pem;
ssl_certificate_key /home/admin/conf/web/ssl.my.site.key;
error_log /var/log/apache2/domains/my.site.error.log error;
location / {
proxy_pass https://10.223.41.249: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;
}
location /error/ {
alias /home/admin/web/my.site/document_errors/;
}
location @fallback {
proxy_pass https://10.223.41.249:3000;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include /home/admin/conf/web/*nginx.my.site.conf_letsencrypt;
include /home/admin/conf/web/snginx.my.site.conf*;
}
Code: Select all
nginx -t
Code: Select all
sudo service nginx restart