Last active
October 12, 2015 10:18
-
-
Save conis/4012087 to your computer and use it in GitHub Desktop.
Nignx根据二级域名和浏览器语言切换到不同的语言版本
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #iove.net | |
| server { | |
| listen 80; | |
| server_name iove.net ; | |
| client_max_body_size 10M; | |
| location / { | |
| proxy_pass http://localhost:1982/; | |
| proxy_set_header Host $host; | |
| proxy_buffering off; | |
| } | |
| } | |
| #purelog.org | |
| server { | |
| listen 80; | |
| server_name purelog.org ; | |
| client_max_body_size 10M; | |
| location / { | |
| proxy_pass http://localhost:13111; | |
| proxy_set_header Host $host; | |
| proxy_buffering off; | |
| } | |
| } | |
| #sales-domain | |
| server { | |
| listen 80; | |
| server_name icicc.com *.icicc.com 52113.com *.52113.com; | |
| location ~* / { | |
| root /var/www/sale-domain; | |
| index index.html; | |
| } | |
| } | |
| #imtime.com | |
| server { | |
| listen 80; | |
| server_name imtime.com *.imtime.com; | |
| charset utf-8; | |
| #access_log logs/host.access.log main; | |
| location ~* \.(js|css|jpeg|jpg|png|zip|crx|safariextz|plist|air|xpi)$ { | |
| root /var/www/imTime.com/html; | |
| index index.html index.htm; | |
| } | |
| #匹配根目录或者html文件 | |
| location ~* (^/$)|(\.html$) { | |
| index index.html index.htm; | |
| #语言 | |
| set $lang 'default'; | |
| #二级域名 | |
| set $subHost ''; | |
| #域名对应的语言 | |
| set $langHost ''; | |
| #=====================检测语言================ | |
| if ($http_accept_language ~* ^zh\-tw){ | |
| set $lang 'zh-tw'; | |
| } | |
| #香港繁体,匹配为繁体 | |
| if ($http_accept_language ~* ^zh\-hk){ | |
| set $lang 'zh-tw'; | |
| } | |
| #新加坡,匹配为繁体 | |
| if ($http_accept_language ~* ^zh\-sg){ | |
| set $lang 'zh-tw'; | |
| } | |
| #匹配简体中文 | |
| if ($http_accept_language ~* ^zh\-cn){ | |
| set $lang 'zh-cn'; | |
| } | |
| #匹配简体中文 | |
| if ($http_accept_language ~* ^zh\.){ | |
| set $lang 'zh-cn'; | |
| } | |
| add_header X-Header $http_accept_language; | |
| #========================配置了主机头,则按主机头走======= | |
| #优先从主机头中匹配 | |
| if ($host ~* ^tw|hk\.) { | |
| set $lang 'zh-tw'; | |
| } | |
| #匹配中文 | |
| if ($host ~* ^cn\.) { | |
| set $lang 'zh-cn'; | |
| } | |
| #匹配英语 | |
| if ($host ~* ^en\.) { | |
| set $lang 'default'; | |
| } | |
| root /var/www/imTime.com/html/$lang; | |
| } | |
| #匹配api,交给node.js处理 | |
| location ~* /(\w+)(\/\w+)?$ { | |
| proxy_pass http://127.0.0.1:3000; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment