0
worker_processes 1;

events {
    worker_connections 1024;
}

http {
    # Logging directives
    error_log logs/error.log;
    access_log logs/access.log;

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

    sendfile        on;
    keepalive_timeout 65;

    # Compression to improve performance
    gzip on;
    gzip_types text/plain application/json text/css application/javascript;

    # HTTP Server: Redirect all HTTP traffic to HTTPS
    server {
        listen 80;
        server_name paisebachaao.in;  # Replace with your domain

        # Redirect all traffic to HTTPS
        return 301 https://$host$request_uri;
    }

    # HTTPS Server
    server {
        listen 443 ssl;
        server_name paisebachaao.in;  # Replace with your domain

        # Path to SSL certificate and private key
        ssl_certificate "C:/OpenSSL/bin/certificate.crt";  # Replace with your actual path
        ssl_certificate_key "C:/OpenSSL/bin/private.key";  # Replace with your actual path

        # Strong SSL settings
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;
        ssl_ciphers HIGH:!aNULL:!MD5;

        # Proxy requests to FastAPI backend
        location / {
            proxy_pass http://127.0.0.1:8000;  # FastAPI running locally
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }

        # Custom error pages
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
            root html;
        }
    }
}

I am using this nginx.conf file as my nginx config file. Somehow I am still able to hit http request with redirecting and https requests are not working on my server, though My inbound 443 port is allowed in my VM.

Can Someone tell me, How to get over this problem with nginx configuration issue. Well When I am restarting this nginx with this configuration, it is asking me for the PEM parse Key but still it is not working for https request

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.