server {
listen 80;
server_name site.ru www.site.ru;
if ($http_user_agent ~* (iphone|аndroid|blackberry)){
rewrite ^/(.*)$ m.site.ru/$1 permanent;
}
location / {
auth_basic "Enter pass:";
auth_basic_user_file /var/www/nginx/passwords;
root /var/www/site.ru/html/application;
index index.html;
charset utf-8;
proxy_pass http://localhost:1337/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name m.site.ru www.m.site.ru;
location / {
auth_basic "Enter pass:";
auth_basic_user_file /var/www/nginx/passwords;
root /var/www/site.ru/html/mobile;
index index.html;
charset utf-8;
proxy_pass http://localhost:1337/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name site.ru www.site.ru;
if ($http_user_agent ~* (iphone|аndroid|blackberry)){
rewrite ^/(.*)$ http://m.site.ru/$1 permanent;
}
location / {
auth_basic "Enter pass:";
auth_basic_user_file /var/www/nginx/passwords;
root /var/www/site.ru/html/application;
index index.html;
charset utf-8;
proxy_pass http://localhost:1337/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name m.site.ru;
root /var/www/site.ru/html/mobile;
index index.html;
}
server {
listen 80;
server_name site.ru;
if ($http_user_agent ~* "(iphone|android|blackberry)") {
rewrite ^ http://m.site.ru redirect;
break;
}
location / {
root /var/www/site.ru/html/application; #статика
index index.html;
charset utf-8;
proxy_pass http://localhost:1337; #здесь у нас висит Node.js - отправляем все запросы сюда
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
server {
listen 80;
server_name m.site.ru;
location / {
root /var/www/site.ru/html/mobile; #статика мобильного сайта
index index.html;
charset utf-8;
}
location /api { #перенаправляем все ajax запросы m.site.ru к api
proxy_pass http://localhost:1337;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}