Skip to content

[INSTALLATION] How to use with default.conf that redirects all HTTP -> HTTPS traffic #507

Open
@cca32

Description

@cca32

Awesome package! Works great. This is a very silly question as my knowledge of nginx isn't very strong.

I have the following default.conf:

# routes all http to https
server {
    listen 80;
    listen [::]:80;

    server_name _;
    server_tokens off;

    ##
    # Nginx Bad Bot Blocker Includes
    # REPO: https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker
    ##s
    include /etc/nginx/bots.d/ddos.conf; 
    include /etc/nginx/bots.d/blockbots.conf;
    
    location / {
        return 301 https://$host.com$request_uri;
    }
}

So it works for all HTTP traffic. I then have other .conf files with the corresponding https traffic which do not get protected.
Am I using nginx design in an anti-pattern way?

What would be the best way to redirect all http traffic to https , and only have to provide the appropriate include files only once?

Thanks!

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions