以此博客为例,服务器使用腾讯云,域名来自阿里云。
124.221.197.179http://localhost:30003000
http://124.221.197.179:3000 访问到项目124.221.197.179
http://www.lidoc.top:3000 访问到项目虽然已经可以访问到项目,但是 url 后跟端口号并不好,这一步就是将 3000 端口的项目转发到 80 端口。(80 端口是默认端口,直接使用域名访问)
nginx/conf/nginx.conf文件进行配置worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
# 服务1 www.lidoc.top访问3000端口
server {
listen 80;
server_name www.lidoc.top; #域名或服务器ip
location / {
proxy_pass http://localhost:3000;
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# 服务2 sicily.lidoc.top访问4000端口
server {
listen 80;
server_name sicily.lidoc.top; #域名或服务器ip
location / {
proxy_pass http://localhost:4000;
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
mac 上的终端工具,可以使用 ssh 连接服务器输入前面的命令之后 按 Tab 键可以自动补全
# ssh [用户名]@[服务器ip]
ssh Administrator@124.71.239.49
Profiles -> Open Profiles -> Edit Profiles -> 左下角 +General -> Basics -> Name输入名称General -> Command -> Command输入ssh Administrator@124.71.239.49Profiles 就可以看到刚才创建的连接,点击连接即可协议:SFTP
主机:124.71.239.49
端口:不填或者22
登录类型: 正常
用户:XX
密码:xx