D
D
dotruger372021-01-27 17:20:05
Nginx
dotruger37, 2021-01-27 17:20:05

How to disable https proxying in nginx?

Faced a problem: you need to remove proxying on https. Tk no longer needs to be proxyed there.
Tell me, what else do I need to remove so that requests come only to http?

upstream django_backend {
        server 127.0.0.1:8080 max_fails=3 fail_timeout=10s weight=2;
        server 127.0.0.1:8081 max_fails=1 fail_timeout=10s weight=1;
        server 127.0.0.1:8082 max_fails=1 fail_timeout=10s weight=1;
}

proxy_hide_header Server;

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    charset utf-8;

    location = /favicon.ico { access_log off; log_not_found off; }

    location / {
        root /home/parallels/Desktop/ask-timonin/static;
        try_files $uri $uri/hello.html =404;
    }

location = /test {
                return 301 /;
        }

    location = /status {
                stub_status;
        }

    location /static {
        root /home/parallels/Desktop/ask-timonin;
    }

    location /uploads {
        root /home/parallels/Desktop/ask-timonin;
    }

    location /legacy {
        include proxy_params;
        proxy_pass http://django_backend/api/v1;
        }

    location /api/v1 {
        include proxy_params;
        proxy_pass http://django_backend;
    }    

set $backend http://django_backend;
    if ($request_method = POST) {
        set $backend http://127.0.0.1:8081;
    }

    location /api/v2 {
        include proxy_params;
        proxy_pass $backend;
    }

    location /admin/ {
        include proxy_params;
        proxy_pass http://localhost:5050/;
        proxy_set_header X-Script-Name /admin;
    }

    gzip on;
    gzip_comp_level 6;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
}   
    
proxy_cache_path /var/cache/nginx_cache levels=1:2 keys_zone=backcache:8m max_size=50m;
proxy_cache_valid 200 302 10m;
proxy_cache_valid 404 1m;

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