title: Nginx two server blocks listen on 80 and 81 not working
body: <p>Inside /etc/nginx/sites-available I have these two three files:</p>
  <p>default</p>
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 ipv6only=on default_server;
  
      root /var/www/html;
      index index.html index.htm index.nginx-debian.html;
      server_name _;
  
      location / {
          # First attempt to serve request as file, then
          # as directory, then fall back to displaying a 404.
          try_files $uri $uri/ =404;
      }
  }
  include /etc/nginx/sites-available/ios_conciseph.conf;
  include /etc/nginx/sites-available/conciseph.conf;
  </code></pre>
  <p>conciseph.conf</p>
  <pre><code>server{
      listen 80;
      server_name staging.app.conciseph.com;
      passenger_enabled on;
      passenger_spawn_method direct;
      passenger_min_instances 1;
      passenger_app_env staging;
      #passenger_ruby /usr/local/rvm/rubies/ruby-2.7.0/bin/ruby;
      passenger_ruby /usr/local/rvm/gems/ruby-2.7.0/wrappers/ruby;
      root /var/www/conciseph/public;
      location ~ ^/assets/ {
          gzip_static on;
          add_header Cache-Control public;
          expires 4w;
          gzip on;
          gzip_vary on;
          gzip_proxied any;
          gzip_disable &quot;MSIE [1-6]\.&quot;;
          gzip_comp_level 6;
          gzip_types application/x-javascript text/css text/html image/x-icon image/png image/jpeg image/gif image/jpg;
      }
      location / {
          root /var/www/conciseph/public;
          autoindex off;
          #proxy_cache conciseph;
          proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
          proxy_cache_revalidate on;
          proxy_cache_min_uses 2;
          proxy_cache_lock on;
          passenger_enabled on;
          log_not_found off;
          if ($http_user_agent ~ (libwww|Wget|LWP|damnBot|BBBike|java|spider|crawl) ) {
              return 403;
          }
      }
      location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control &quot;public&quot;;
      }
  
  }
  </code></pre>
  <p>ios_conciseph.conf</p>
  <pre><code>server{
      listen 81;
      server_name staging.app.conciseph.com:81;
      passenger_enabled on;
      passenger_spawn_method direct;
      passenger_min_instances 1;
      passenger_app_env staging;
      #passenger_ruby /usr/local/rvm/rubies/ruby-2.7.0/bin/ruby;
      passenger_ruby /usr/local/rvm/gems/ruby-2.7.0/wrappers/ruby;
      root /var/www/ios_conciseph/conciseph/public;
      location ~ ^/assets/ {
          gzip_static on;
          add_header Cache-Control public;
          expires 4w;
          gzip on;
          gzip_vary on;
          gzip_proxied any;
          gzip_disable &quot;MSIE [1-6]\.&quot;;
          gzip_comp_level 6;
          gzip_types application/x-javascript text/css text/html image/x-icon image/png image/jpeg image/gif image/jpg;
      }
      location / {
          root /var/www/ios_conciseph/conciseph/public;
          autoindex off;
  #        proxy_cache conciseph;
          proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
          proxy_cache_revalidate on;
          proxy_cache_min_uses 2;
          proxy_cache_lock on;
          passenger_enabled on;
          log_not_found off;
          if ($http_user_agent ~ (libwww|Wget|LWP|damnBot|BBBike|java|spider|crawl) ) {
              return 403;
          }
      }
      location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control &quot;public&quot;;
      }
  
  }
  </code></pre>
  <p>when I hit staging.app.conciseph.com/users/sign_up it gives me expected response
  but when I hit staging.app.conciseph.com:81/users/sign_up it keeps on loading and eventually raises error 'This site can not be reached'</p>
  <p>I can not even find any request being processed in the /var/log/nginx/access.log</p>
  <p>I want to run same app using two diferent urls.</p>
  <p>folder one is inside : /var/www/conciseph &amp;
  folder two path: /var/www/ios_conciseph/conciseph</p>