再会!
有一个任务是发布在 nodejs 上编写的 api。VPS 已经安装了 nginx + phpmyadmin(mysql) 并且需要添加 node.js。
目录
nodejs = /var/www/node
nginx 静态文件(原则上不需要它们,因为这是一个 api)=
nginx = var/www/html
事实证明,请使用 nginx conf 文件配置工作node
或phpmyadmin
帮助。
/etc/nginx/sites-available/default(使用工作 phpmyadmin)
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name xxx.xxx.xxx.xxx;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
通过删除 phpmyadmin 并改用 MySQL Workbench 的桌面版本解决了该问题。
与此相关,配置更改为此(ssl)
server {
server_name xxxxxxx.ru www.xxxxxxx.ru;
location / {
proxy_pass http://localhost: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;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/gmelum.ru/fullchain.pem; # managed by$
ssl_certificate_key /etc/letsencrypt/live/gmelum.ru/privkey.pem; # managed $
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.xxxxxxxx.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = xxxxxxxx.ru) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name xxxxxxx.ru www.xxxxxxx.ru;
return 404; # managed by Certbot
}
您可以通过该位置的代理对其进行配置,通过 supervisord 或替代方式单独运行和监视 Node 服务器的状态。源位置的示例配置:
Nginx 可以与 CGI(通用网关接口)一起使用,也可以作为静态资源或不受支持的服务器应用程序(如 Node.js)的代理。