title: How to configure apache as a reverse proxy for asp.net core
body: <p>I'm trying to deploy aspo.net core MVC application to a linux server - centos - with apache as a reverse proxy, and so far i was following this link </p>
  
  <p><a href="https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-2.2" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-2.2</a></p>
  
  <p>and i tried to run the application on the server to make sure that it's working, and it said that <em>port 5000</em> is in use, so i changed the port by this code in the <strong>program.cs</strong> file ...</p>
  
  <pre><code>public static void Main(string[] args)
          {
              BuildWebHost(args).Run();
          }
  
          public static IWebHost BuildWebHost(string[] args) =&gt;
              WebHost.CreateDefaultBuilder(args)
              .UseStartup&lt;Startup&gt;()
              .UseKestrel(options =&gt;
              {
                  options.Listen(IPAddress.Loopback, 9009);
              })
              .UseContentRoot(Directory.GetCurrentDirectory())
              .Build();
  </code></pre>
  
  <p>and it ran in the server on port 9009 
  but the problem is that i can't access it.
  i tried to access by the ip address <em>138.201.131.247:9009</em>
  and tried to access by the domain name <em><a href="http://medicalrecords.host:9009" rel="nofollow noreferrer">http://medicalrecords.host:9009</a></em>
  even i tried to ping to it through terminal with </p>
  
  <pre><code>ping 127.0.0.1:9009
  </code></pre>
  
  <p>it shows this message</p>
  
  <pre><code>[root@server ~]# ping 127.0.0.1:9009
  ping: 127.0.0.1:9009: Name or service not known
  </code></pre>
  
  <p>but nothing work
  and i tried to configure apache to working as a reverse proxy by this code </p>
  
  <pre><code>&lt;VirtualHost *:*&gt;
      RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *:80&gt;
      ProxyPreserveHost On
      ProxyPass / http://127.0.0.1:9009/
      ProxyPassReverse / http://127.0.0.1:9009/
      ServerName medicalrecords.host
      ServerAlias medicalrecords.host
      ErrorLog /var/log/apache2/testapp-error.log
      CustomLog /var/log/apache2/testapp-access.log common
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>and also not working.
  <strong>* Note That *</strong> there are multiple domain running on this apache server as it serving them and it configured by domain name, i don't know if this is the problem or not but i tried every thing but not the solution :D.
  Thanks alot.</p>