Welcome! Log In Create A New Profile

Advanced

proxy_pass to subdomain does not work

proxy_pass to subdomain does not work
March 26, 2019 10:14AM
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;
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 227
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready