J
J
Justique2018-10-04 13:47:42
Nginx
Justique, 2018-10-04 13:47:42

Why does nginx redirect to port 80 if listen 7777 is set?

Centos + Nginx + httpd
The essence of the problem:
The first input on which the back works on port 8080, and the front on 80

nginx vhost1
server {
listen 80;
server_name ********;
#access_log /website/name.site/logs/nginx_access.log;
error_log /var/www/crmMSK/logs/nginx_error.log;

location / {
proxy_pass http://127.0.0.1:8080/;
proxy_read_timeout 300s;
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_buffering off;
}

location ~* \.(css|js|png|gif|jpg|jpeg|ico)$ {
root /var/www/crmMSK;
expires 1d;
}

location ^~ /phpmyadmin/
{
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
httpd1
<VirtualHost *:8080>
 ServerName *********
 DocumentRoot /var/www/crmMSK
 <Directory /var/www/crmMSK>
 Options FollowSymLinks
 AllowOverride All
 Require all granted
 </Directory>
 ErrorLog /var/www/crmMSK/logs/error.log
 CustomLog /var/www/crmMSK/logs/access.log common
</VirtualHost>

Second input, back on port 8081, front on port 7777
nginx vhost2
server {
listen 7777;
server_name ********;
#access_log /website/name.site/logs/nginx_access.log;
error_log /var/www/crmMSK/logs/nginx_error.log;

location / {
proxy_pass http://127.0.0.1:8081/;
proxy_read_timeout 300s;
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_buffering off;
}

location ~* \.(css|js|png|gif|jpg|jpeg|ico)$ {
root /var/www/crmMSK;
expires 1d;
}

location ^~ /phpmyadmin/
{
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
httpd2
<VirtualHost *:8081>
 ServerName *******
 DocumentRoot /var/www/crmBLR
 <Directory /var/www/crmBLR>
 Options FollowSymLinks
 AllowOverride All
 Require all granted
 </Directory>
 ErrorLog /var/www/crmBLR/logs/error.log
 CustomLog /var/www/crmBLR/logs/access.log common
</VirtualHost>

so, the first input works as it should, but the second one redirects to 80 instead of 7777

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TyzhSysAdmin, 2018-10-04
@POS_troi

Check the back, and specifically its config, I don’t know what is there, but in this whole bunch, only the back can do this.
Although the front can, but there is less chance of fixing it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question