http proxy:
#列出所有服務器地址,nginx 自動均衡分發請求到各個服務器。
upstream frontends {
ip_hash;
server 192.168.199.1:8088;
server 192.168.199.2:8089;
}
server {
listen 80;
server_name mydomain.com www.mydomain.com;
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://frontends;
}
#靜態資源交由nginx管理
location /static {
root /var/www/mydomain/web;
expires 1d;
add_header Cache-Control public;
access_log off;
}
}`
fastcgi:
server {
listen 80;
server_name www.xxxxxxx.xxx; #這裏可以配置域名,如果需要支持多個網站的話 #如果需要可以配置訪問日誌
#access_log /var/log/nginx/log/host.access.log main;
#以下是對靜態資源訪問的配置, 例如 css img 神馬的
location ~ ^/css|img|js|tpl/ {
root /data/www/xxxxx/; #expires 4d; #如果需要也可以配置緩存過期時間
}
location / {
root /data/www/xxxxxx/;
index index.html index.htm;
fastcgi_pass 127.0.0.1:9001; #需要分配一個端口號給go-fastcgi
fastcgi_index index; #這是Go的入口
client_max_body_size 10m;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}