一,启动应用:
1,编译程序
$ go build
2,用nohup启动应用的二进制程序
$ nohup /data/goapp/industry/industry >> /data/logs/gologs/back.log 2>&1 &
[1] 4896
3,检查应用是否启动:
$ ss -lntp | grep 3000
LISTEN 0 4096 0.0.0.0:3000 0.0.0.0:* users:(("industry",pid=4896,fd=3))
可以看到已经绑定了端口
二,配置nginx
添加一个server
server {
listen 3080;
server_name localhost;
access_log /data/logs/nginxlogs/industry-access.log;
error_log /data/logs/nginxlogs/industry-error.log;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
重启ninx
# systemctl restart nginx.service
三,测试效果:
已可以从3080端口返回
标签:log,0.0,industry,golang,nginx,上用,proxy,data From: https://www.cnblogs.com/architectforest/p/18547892