nginx +golang
2013-12-04 10:12
260 查看
nginx 配置
01 | #列出所有服务器地址,nginx 自动均衡分发请求到各个服务器。 |
02 | upstream frontends { |
03 | ip_hash; |
04 | server 192.168.199.1:8088; |
05 | server 192.168.199.2:8089; |
06 | } |
07 | server { |
08 | listen 80; |
09 | server_name mydomain.com www.mydomain.com; |
10 | location / { |
11 | proxy_pass_header Server; |
12 | proxy_set_header Host $http_host; |
13 | proxy_redirect off; |
14 | proxy_set_header X-Real-IP $remote_addr; |
15 | proxy_set_header X-Scheme $scheme; |
16 | proxy_pass http://frontends;[/code] |
17 | } |
18 |
19 | #静态资源交由nginx管理 |
20 | location /static { |
21 | root /var/www/mydomain/web; |
22 | expires 1d; |
23 | add_header Cache-Control public; |
24 | access_log off; |
25 | } |
26 | }` |
2. [代码]go程序试用http监听
01 | //this host ip 192.168.199.1 |
02 | func main() { |
03 | ... |
04 | http.ListenAndServe( ":8088" , nil) |
05 | os.Exit(0) |
06 | } |
07 |
08 | ... |
09 | //other |
10 | //this host ip 192.168.199.2 |
11 | func main() { |
12 | ... |
13 | http.ListenAndServe( ":8089" , nil) |
14 | os.Exit(0) |
15 | } |
相关文章推荐
- Ubuntu 下 nginx , php , mysql 和 golang 的简单安装
- golang—nginx-lua学习相关
- 用golang fastcgi与nginx配合写web
- 很久没来,丢一份前阵子做的 10 万连接性能测试 (fibjs, golang, nginx, nodejs)
- linux 部署golang 项目(直接部署和基于nginx部署)
- nginx 反向代理 golang web
- nginx作Golang反向代理服务器
- ubuntu golang nginx
- golang JSON webservice - nginx load balance
- Ubuntu 下 nginx , php , mysql 和 golang 的简单安装
- 使用Nginx作为Web服务器的国内网站[原创]
- apache 与 nginx 404 配置
- Keepalived+Nginx实现高可用和双主节点负载均衡
- Awstats分析nginx日志
- 【Nginx笔记】 fastcgi_param解释 转
- nginx 重写 rewrite 基础及实例
- nginx精准匹配, 一般匹配, 正则匹配
- 【Nginx】Tengine+Keepalived实现主从模式双机热备
- 【GoLang】golang TCP 粘包处理 示例
- Ubuntu 环境下,卸载Nginx后重装失败的处理方法