Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

proxy_pass to subdomain does not work

$
0
0
I have configured a reverse proxy that according to the url is redirected to a subdomain.

Example:
xxxx.domain.com -> test1.computer.com
zzzz.domain.com -> test2.computer.com

The problem is that wherever you enter, always redirect to a single server
xxxx.domain.com -> test1.computer.com
zzzz.domain.com -> test1.computer.com

configuration proxy reverse:

server {
listen 443 ssl http2;
server_name xxxx.domain.com
location / {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://test1.computer.com;
}
}
server {
listen 443 ssl http2;
server_name zzzz.domain.com
location / {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://test2.computer.com;
}
}

Configuration backend
server {
listen 80;
server_name test1.computer.com;
root /var/www/html/test1;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ =404;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}

server {
listen 80;
server_name test2.computer.com;
root /var/www/html/test2;
index index.php index.html index.htm;

location / {
try_files $uri $uri/ =404;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>