-2

I have a situation where I need to listen for http and https on same port(8099) and serve the same content to both http and https requests. My config file for https is given below. I have tried adding listen 8099; to the server block but thats not helping.

worker_processes  auto;

events {
    worker_connections  4096;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    proxy_connect_timeout 3200s;
    proxy_read_timeout 3000s;
    #gzip  on;

    server    {
       
    listen               8099 ssl http2;
    ssl                  on;
    ssl_certificate      C:/cert/letsencrypt.crt; 
    ssl_certificate_key  C:/cert/letsencrypt-decrypted.key; 
    #ssl_protocols TLSv1.2;
    ssl_buffer_size 4k;   
    ssl_session_tickets off;    
    ssl_session_cache shared:SSL:5m;
    ssl_session_timeout 60m;    

    access_log off;

        location / {
            try_files $uri $uri/ /index.html;
                  }
                  
        location /ort/{
        
            proxy_pass http://localhost:8042;
            proxy_set_header Authorization "Basic YWxuYXNnjiiBhY3M6YWxuYXNhcnBhY3M1Nzc=";
            proxy_set_header HOST $Host:8099/ort/;
            proxy_set_header X-Real-IP $remote_addr;

            rewrite /ort(.*) $1 break;
                           }              
       
    }}
New contributor
ranasrule is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
7
  • 2
    yeah, nginx won't serve http and https on the same port Oct 3 at 9:07
  • 6
    Normally you have either plain HTTP or TLS secured HTTPS on one port and the typical web server does not support both at the same time. That requires a protocol demultiplexer like sslh github.com/yrutschle/sslh
    – HBruijn
    Oct 3 at 9:07
  • Why do you need to do that?
    – vidarlo
    Oct 3 at 10:17
  • I was not aware of sslh (ty @HBrujin) but even it works reliably, is it a good idea? Methinks not.
    – symcbean
    Oct 3 at 10:44
  • Actually it is possible to some extend. But really, why?
    – Alexey Ten
    Oct 3 at 12:16

0

You must log in to answer this question.

Browse other questions tagged .