Прокси
Проксирование запроса без изменения URL
Nginx proxy domain to another domain with no change URL
Пример реализует проксирование запросов к папке uploads на старом сайте
server { listen [IP]:80; server_name new-domain.ru; root /home/new-domain.ru/httpdocs/web; index index.php; access_log /var/log/nginx/new-domain.ru.access.log; error_log /var/log/nginx/new-domain.ru.error.log error; charset utf-8; #charset windows-1251; location = /favicon.ico { log_not_found off; access_log off; break; } location = /robots.txt { allow all; log_not_found off; access_log off; } location / { index index.php; # Запороливание доступа к сайту #auth_basic "Website development"; #auth_basic_user_file /home/new-domain.ru/authfile; try_files $uri $uri/ /index.php?$query_string; } location ~ /(protected|themes/\w+/views)/ { access_log off; log_not_found off; return 404; } location ~ uploads/ { expires 30d; log_not_found off; access_log off; add_header X-media-header media-header-content; # Обращаемя за контентом к старому сайту proxy_pass http://127.0.0.1:80; proxy_redirect off; proxy_hide_header "Cache-Control"; add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"; proxy_hide_header "Pragma"; add_header Pragma "no-cache"; add_header Last-Modified $sent_http_Expires; proxy_set_header Host new-domain.ru; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; break; } #отключаем обработку запросов фреймворком к несуществующим статичным файлам location ~ \.(js|css|ico|png|jpg|gif|ico)$ { expires 30d; log_not_found off; access_log off; add_header X-media-header media-header-content; break; } # Подключаем обработчик location ~ \.php { #try_files $uri =404; include fastcgi_params; # Use your own port of fastcgi here #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php-fpm-new-domain.ru.sock; fastcgi_index index.php; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } # Прячем все системные файлы location ~ /\. { deny all; access_log off; log_not_found off; } }
- [IP] - Указываем IP нашего сервера