![](/img/trans.png)
[英]Using node.js for my server, need to setup user accounts, which database program should I use?
[英]i need to setup my domain with nginx server for node.js project
我已经在服务器中添加了CNAME&A Record,也使用nginx命令进行了检查:
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
我为域example.co和www.example.co编写代码:/etc/nginx/sites-available/example.conf
server {
listen 80;
listen [::]:80;
server_name example.co www.example.co;
return 301 $scheme://www.example.co$request_uri;
}
server {
listen 443 ssl http2 ;
listen [::]:443 ssl http2 ;
server_name example.co www.example.co;
access_log /var/log/nginx/example-co.log;
location / {
proxy_pass "http://127.0.0.1:1000";
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;
}
ssl_certificate /etc/letsencrypt/live/example.co/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.co/privkey.pem;
}
IP:例如example.co的127.0.0.1:1000 node.js项目,我的问题是example.co正常运行,但www.example.co无法正常运行
我也为我的域sub1.example.co和www.sub1.example.co编写了代码:/etc/nginx/sites-available/sub1-example.conf
server {
listen 80;
listen [::]:80;
server_name sub1.example.co www.sub1.example.co;
return 301 $scheme://www.example.co$request_uri;
}
server {
listen 443 ssl http2 ;
listen [::]:443 ssl http2 ;
server_name sub1.example.co www.sub1.example.co;
access_log /var/log/nginx/sub1-example-co.log;
location / {
proxy_pass "http://127.0.0.1:2000";
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;
}
ssl_certificate /etc/letsencrypt/live/example.co/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.co/privkey.pem; # managed by Certbot
}
IP:sub1.example.co的IP:127.0.0.1:2000 node.js项目,
我的sub1.example.co无法运作
您需要使用443
将www.example.co
添加到服务器块:
server {
.....
server_name example.co www.example.co;
.....
}
对于您的子域,建议使用相同格式的服务器块配置使用另一个文件:一个服务器块用于80,另一个服务器块用于443。:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.