title: Remote Access to Local ASP.NET Core app NGINX
body: <p>I published my <strong>ASP.NET Core</strong> app on my <strong>raspberrypi3</strong> (raspbian) with <strong>nginx</strong>.</p>
  
  <p>I configured nginx following the microsoft documentation: on localhost everything works correctly but I can't access the app from other devices on my local network (ERR_CONN_REFUSED).</p>
  
  <p>I set the reverse proxy on port 81 because on port 80 I have another server that manages php sites (including phpmyadmin) like this:</p>
  
  <pre><code>server {
  listen 80 default_server;
  listen [::]:80;
  
  root /var/www/html;
  
  index index.php index.html index.htm index.nginx-debian.html;
  
  server_name php.it *.php.it;
  
  location / {
  
      try_files $uri $uri/ =404;
  }
  
  
  location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      fastcgi_pass unix:/run/php/php7.3-fpm.sock;
  }}
  </code></pre>
  
  <p>and</p>
  
  <pre><code>server {
  listen 81;
  
  server_name example.com *.example.com;
  
  location / {
      proxy_pass         http://localhost:5000;
      proxy_http_version 1.1;
      proxy_set_header   Upgrade $http_upgrade;
      proxy_set_header   Connection keep-alive;
      proxy_set_header   Host $host;
      proxy_cache_bypass $http_upgrade;
      proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header   X-Forwarded-Proto $scheme;
  }}
  </code></pre>
  
  <p>I don't know if the problem is in the configuration of the <code>/etc/nginx/sites-available/default</code> file or in the asp.net Core application.
  I think the problem is localhost, but I have no idea how to solve it.</p>
  
  <p>Also, I'm not sure what I should put in server_sites, what does it refer to?
  Thanks</p>