dimanche 27 juin 2021

How to disable redirection of http to https (Nginx, CertBot)

Im trying to not redirect http to https....

I tried to research but found nothing...

BTW I DID BOTH THIS COMMANDS TO MAKE NEW FILE INSTEAD OF USING DEFAULT FILE ON SITES ENABLED:

sudo touch /etc/nginx/sites-available/imallbd
sudo nano /etc/nginx/sites-available/imallbd

then:

sudo ln -s /etc/nginx/sites-available/imallbd /etc/nginx/sites-enabled/imallbd

This is my sites-enabled file

server {

    server_name imallbd.com;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # For API
    location /api {
        alias /var/www/imallbd/api/public;
        try_files $uri $uri/ @api;
            location ~ \.php$ {
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_pass   unix:/run/php/php7.4-fpm.sock;
         }
    }

    location @api {
      rewrite /api/(.*)$ /api/index.php?/$1 last;
    }

    # For FrontEnd -> GraphQL
    location /{
        proxy_pass http://localhost:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    location /admin{
        proxy_pass http://localhost:3000/admin;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

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

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/imallbd.com/fullchain.pem; # managed >
    ssl_certificate_key /etc/letsencrypt/live/imallbd.com/privkey.pem; # manage>
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot




}
server {
    if ($host = imallbd.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;

    server_name imallbd.com;
    return 404; # managed by Certbot


}

pls help!!! btw when i go to my website it gives me 502 bad gateway... ik thats not the question im asking but if you can give me some help tips or the answer i would be so grateful :)

when i run:

sudo nginx -t

   nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
   nginx: configuration file /etc/nginx/nginx.conf test is successful

If you want more details or information i can give, just tell me on the comments!

THANKS IN ADVANCE!!!




Aucun commentaire:

Enregistrer un commentaire