12
Jun
2023

Ubuntu Nodejs google analytics rpject

Step 1. Install Nodejs

Step 2. Copy the files to the folder

Step 3. Install Nginx

Step 4. Start the Nginx servier: sudo service nginx start

Step 5. Add the proxy to Nginx.conf file:

server {

listen 80;
listen [::]:80;
server_tokens off;

# 可以修改为自己的域名
server_name apple.ideaitweb.com;
# 访问 / 访问的目录

# 反向代理到node服务
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Nginx-Proxy true;
proxy_http_version 1.1;
# Node.js的本机地址,注意端口
proxy_pass http://localhost:4000;
proxy_read_timeout 24h;
}
}

Step 6. 安装Google sdk:

sudo apt-get install apt-transport-https ca-certificates gnupg curl sudo

echo “deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main” | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list

Step 7 restart Nginx:

sudo service nginx restart

Step 8 运行app.js: sudo node app.js

Share

You may also like...