Issue
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
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-apache?view=aspnetcore-2.2
and i tried to run the application on the server to make sure that it's working, and it said that port 5000 is in use, so i changed the port by this code in the program.cs file ...
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Listen(IPAddress.Loopback, 9009);
})
.UseContentRoot(Directory.GetCurrentDirectory())
.Build();
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 138.201.131.247:9009 and tried to access by the domain name http://medicalrecords.host:9009 even i tried to ping to it through terminal with
ping 127.0.0.1:9009
it shows this message
[root@server ~]# ping 127.0.0.1:9009
ping: 127.0.0.1:9009: Name or service not known
but nothing work and i tried to configure apache to working as a reverse proxy by this code
<VirtualHost *:*>
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
</VirtualHost>
<VirtualHost *:80>
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
</VirtualHost>
and also not working. * Note That * 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.
Solution
I Believe the problem was the port specified in the apache configuration, it was the same for apache general request, i changed it to 90 and it worked fine for me, along with the answer @itminus said to change that line in the API opts.ListenAnyIP(9009);
to listen to any default port in the server. Thanks alot.
Answered By - Hassan Ahmed Answer Checked By - Mildred Charles (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.