edgemesh icon indicating copy to clipboard operation
edgemesh copied to clipboard

How i can redirect from HTTP TO HTTPS in Nginx.conf????

Open abhinavjha126 opened this issue 3 years ago • 2 comments

I am using KubeEdge v1.8.1.

My Nginx.conf looks like this

apiVersion: v1 kind: ConfigMap metadata: name: confnginx namespace: default data: nginx.conf: | user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; 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; keepalive_timeout 65;

  server {
    listen 443;

    server_name ~^(?<subdomain>.*?)\.;
    resolver kube-dns.kube-system.svc.cluster.local valid=5s;

    location /healthz {
      return 200;
    }
    
    location / {
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_pass http://$subdomain.*.svc.cluster.local;
      proxy_set_header Host $host;
      proxy_http_version 1.1;
    }
  }

  server {
    listen 80;

    server_name ~^(?<subdomain>.*?)\.;
    resolver kube-dns.kube-system.svc.cluster.local valid=5s;

    location /healthz {
      return 200;
    }
    
    location / {
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_pass http://$subdomain.*.svc.cluster.local;
      proxy_set_header Host $host;
      proxy_http_version 1.1;
    }
  }
}

HOW CAN I REDIRECT HTTP TO HTTPS??? I NEED THAT USERS ABLE TO OPEN HTTPS PAGE EVEL IF THEY SIMPLY TYPE http...i want redirection....How is it possible??

abhinavjha126 avatar Apr 25 '22 06:04 abhinavjha126

You can refer to: https://edgemesh.netlify.app/guide/edge-gateway.html#https-gateway

Poorunga avatar Apr 26 '22 09:04 Poorunga

@Poorunga In that link http and https use are given separately....i want that http link is redirected to https...i want solution for that,please help

abhinavjha126 avatar Apr 26 '22 12:04 abhinavjha126