linux:nginx-basic-auth
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | linux:nginx-basic-auth [2019/10/21 12:30] (current) – created percy | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Nginx Basic Auth ====== | ||
+ | ====== Enable the basic auth in Nginx config ====== | ||
+ | |||
+ | I just enable it for the path "/ | ||
+ | ``` | ||
+ | location /upload { | ||
+ | try_files $uri $uri/ / | ||
+ | autoindex on; | ||
+ | auth_basic "nginx basic http auth"; | ||
+ | auth_basic_user_file conf/ | ||
+ | } | ||
+ | ``` | ||
+ | |||
+ | So the whole will be | ||
+ | ```file | ||
+ | server { | ||
+ | listen 8000; | ||
+ | server_name sap.pjq.me ddns.pjq.me; | ||
+ | return 301 https:// | ||
+ | } | ||
+ | server { | ||
+ | listen 8443; | ||
+ | server_name sap.pjq.me ddns.pjq.me; | ||
+ | ssl on; | ||
+ | ssl_session_timeout 5m; | ||
+ | root / | ||
+ | index index.html index.htm index.php; | ||
+ | location / { | ||
+ | try_files $uri $uri/ / | ||
+ | autoindex on; | ||
+ | } | ||
+ | location /upload { | ||
+ | try_files $uri $uri/ / | ||
+ | autoindex on; | ||
+ | auth_basic "nginx basic http auth"; | ||
+ | auth_basic_user_file conf/ | ||
+ | } | ||
+ | location ~ \.ini$ { | ||
+ | return 444; | ||
+ | } | ||
+ | location ~ \.php$ { | ||
+ | try_files $uri =404; | ||
+ | fastcgi_pass unix:/ | ||
+ | fastcgi_index index.php; | ||
+ | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
+ | include fastcgi_params; | ||
+ | |||
+ | } | ||
+ | location = / | ||
+ | location = /robots.txt { log_not_found off; access_log off; allow all; } | ||
+ | location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ { | ||
+ | expires max; | ||
+ | log_not_found off; | ||
+ | } | ||
+ | location ~ \.php$ { | ||
+ | fastcgi_split_path_info ^(.+\.php)(/ | ||
+ | fastcgi_pass unix:/ | ||
+ | fastcgi_index index.php; | ||
+ | include fastcgi_params; | ||
+ | } | ||
+ | } | ||
+ | ``` | ||
+ | ====== Generate the username/ | ||
+ | |||
+ | echo " |
/var/www/dokuwiki/wiki/data/pages/linux/nginx-basic-auth.txt · Last modified: 2019/10/21 12:30 by percy