502 bad mvc core gateway application on CentOS

I made a site in MVC Core and tried to publish it online on CentOS 7 VPS. It works well, when I twist it, it responds. Then I installed nginx and it showed the default page when trying to use it from my computer. Then I changed nginx.conf to below and all I get is 502 bad gateways. In the nginx log, I only see that a get request was received. Any ideas what should I check?

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
  #   include /etc/nginx/conf.d/*.conf;
     server {
        listen 80;
        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;
        }
     } 
}

      

+3


source to share


1 answer


I tried apache and had the same problem. Then I found a solution, you need to set httpd_can_network_connect.

http://sysadminsjourney.com/content/2010/02/01/apache-modproxy-error-13permission-denied-error-rhel/



A did not find the error message on the audit blog that the author was talking about, but I tried his solution and it worked.

I have been using centos for 4 days and the second time I need to do a bit of work to fix the problem. These solutions are pretty hidden on the internet and most of the articles on this area don't mention it, so I wasted a lot of time. Therefore, I share the author's opinion about SELinux. I will probably try another Linux distro. Interestingly, too, I followed the official microsoft tutorial "Set up a hosting environment for ASP.NET Core on Linux with Apache and deploy it". The operating system they are using is also CentOS. And he doesn't mention that bit.

+5


source







All Articles