Score:0

How can I disable subdomain connecting in my nginx proxy server port?

mx flag

I have a cloud server that will have several applications running on it. I have a domain already pointed to this server. Now I want to achieve the following:

  1. Have some ports that will be accessed only via IP address

  2. Have some ports that will be accessed only via a sub-domain

  3. Have a port that will be accessed only by the domain

    server{
    listen 3000 ssl http2;
    ssl_certificate certs/certificate.crt; ssl_certificate_key certs/private.key;

     error_page 497 301 =307 https://$host:$server_port$request_uri;
     location / {
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $host;
         proxy_pass http://127.0.0.1:21210;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";     
         proxy_redirect off;
         proxy_set_header Host $host:$server_port;            
         proxy_set_header X-Forwarded-Ssl on;        
     }   
    

    }

    server_name x.x.x.x:3000; # here i the application to be accessed when using an IP on port 3000. Unfortunately, the domain or any subdomain opens this port

Richard Smith avatar
jp flag
If Nginx cannot find a matching `server_name` it will use the [default server](http://nginx.org/en/docs/http/request_processing.html). If you want Nginx to reject connections using the "wrong" Host name, either add another `server` block, or test the value of `$host` and do something.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.