Nginx redirects http and https requests to port 3000. But I'm trying to redirect a subdomain to port 3001 without success, it's being redirected to port 3000. There is no log on errors. Even if I try a http request on port 80 I can't redirect port 3001, all requests goes to 3000.
And I configured the DNS with the subdomain.
My nginx.conf file is:
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name example.com www.example.com;
root /usr/share/nginx/html;
ssl_certificate "/etc/letsencrypt/live/example.com/fullchain.pem";
ssl_certificate_key "/etc/letsencrypt/live/example.com/privkey.pem";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:SEED:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!RSAPSK:!aDH:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!SRP;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:3000;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name example.com.br www.example.com;
return 301 https://example.com;
}
############## THIS PART OF THE CODE IS IGNORED ###################
server {
listen 80;
listen [::]:80;
server_name subdomain.example.com;
location / {
proxy_pass http://127.0.0.1:3001;
}
}
###################################################################
}
It turned out that wasn't a nginx problem, I just had to delete the browser cache.
Everything was correct. I just had to delete the browser cache.