Answer the question
In order to leave comments, you need to log in
How to proxy requests in nginx?
There is a server with a website (mysite.ru) on IIS (server ip 192.168.1.2) + several Asp.net web applications (web1.mysite.ru, web2.mysite.ru ...).
It was required to add a site on ngnix or on apache (the engine on iis does not work, after shamanism it started working, but crookedly). I installed ngnix on the ubuntu virtual machine (server ip 192.168.1.3).
upstream web_servers {
server 192.168.1.2;
server 192.168.1.3;
}
#порт
server {
listen 80;
location / {
proxy_pass http://mysite.ru;
# настройка заголовков
proxy_set_header X-proxy 192.168.1.3;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_next_upstream error timeout invalid_header http_500 http_404;
proxy_set_header X-Client-IP $remote_addr;
}
}
Answer the question
In order to leave comments, you need to log in
server {
listen 80;
server_name mysite.ru;
location / {
proxy_pass http://192.168.1.2;
proxy_set_header X-proxy 192.168.1.3;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Client-IP $remote_addr;
}
}
server {
listen 80;
server_name web1.mysite.ru;
location / {
proxy_pass http://192.168.1.2;
proxy_set_header X-proxy 192.168.1.3;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Client-IP $remote_addr;
}
}
server {
listen 80;
server_name corp1.mysite.ru;
root /var/www/corp1.mysite.ru
Тут описываете свои location для сайта (php/статика/....)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question