server {
server_name ~^www\.(.+)\.example\.com$;
return 301 $1.example.com/$request_uri;
}
upstream putit {
# Адрес back-end'a
server putit.ru:8080;
}
server {
listen 80;
server_name www.putit.ru putit.ru;
access_log /home/username/domains/putit.ru/logs/nginx_access.log;
error_log /home/username/domains/putit.ru/logs/nginx_error.log;
# Перенаправление на back-end
location / {
proxy_pass backend;
include /etc/nginx/proxy.conf;
}
....
}
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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 16k;
proxy_buffers 16 16k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
server {
server_name ~^(?<company>.+)\.site\.ru$;
location / {
try_files /path/to/static/media @django;
}
location @django {
fastcgi_pass unix:/tmp/site.django.socket;
fastcgi_param PATH_INFO /$company$uri;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param REMOTE_ADDR $remote_addr;
}
}
/company1/menu/item
она должна будет создавать ссылку /menu/item
.