P
P
password222021-12-28 02:17:10
Nginx
password22, 2021-12-28 02:17:10

Why 502 error on ubuntu + nginx + asp.net?

Good afternoon. I'm not an administrator, but I'm trying to figure out how to host a site on asp.net under bare ubuntu 20.04. Here is what I did:

  1. Installed nginx
  2. From the official microsoft documentation, I installed sdk, dotnet runtime and aspnetcore (the site itself starts up without errors, I think it's in nginx)
  3. I tried to install php-fpm and accordingly change the settings in the config for it


The site is located at /var/www/html/publish

/etc/hosts
127.0.0.1       localhost
127.0.0.1       myDomen.ru
194.87.232.12   ubuntu20.ruvds.com      ubuntu20

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


/etc/nginx/sites-enabled/default
# Default server configuration
#
server {
        listen 127.0.0.1;
        #listen [::]:80 default_server;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/html/publish;

        # Add index.php to the list if you are using PHP
        #index index.html index.htm index.nginx-debian.html;

        server_name myDomen.ru www.myDomen.ru;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;

                proxy_pass      http://127.0.0.1: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;
        }


/etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

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

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


I run it without a service using sudo dotnet myProject.dll, everything runs without errors

Error when accessing the site from /var/log/nginx/error.log
2021/12/28 01:24:11 [error] 5497#5497: *4 connect() failed (111: Connection refused) while connecting to upstream, client: 196.196.41.68, server: myDomen.ru, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "1434.134.123.123:80"


I've tried everything, I think I don't know something that is rarely talked about.
I will be glad for any help! Thank you

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question