server { listen 80 default; server_name xx.xx.xx.xx; if ( $scheme = "http" ) { rewrite ^/(.*)$ https://$host/$1 permanent; } } server { # listen 80 default; ## listen for ipv4; this line is default and implied listen 443 ssl; # HTTPS (SSL) port include /etc/nginx/conf.d/ssl.conf; # Enable SSL config root /web/tools; index index.php index.html index.htm; # Make site accessible from http://xx.xx.xx.xx/ server_name xx.xx.xx.xx; location / { # First attempt to serve request as file, then # as directory, then fall back to index.html try_files $uri $uri/ /index.html; auth_basic "Unauthorized. Please login"; auth_basic_user_file /web/htpasswd; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_param HTTPS on; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php; } }