On 2014-12-29 at 08:59 CET Tuyosi Takesima wrote:
> Hi ,all .
> 
> how to compile nginx who has ability of basic auth using ports ?
> 
> according to http://wiki.nginx.org/Modules ,
>   if auth_basic is not wanted,
>           compile nginx --without-http_auth_basic_module .
> ---
> i need basic auth because of family privacy photos ,
>    i run nginx on arch linux  out of need .
> 
> nginx.conf is
> worker_processes  1;
> events {
>     worker_connections  1024;
> }
> 
> http {
>     include       mime.types;
>     default_type  application/octet-stream;
>     sendfile        on;
>     keepalive_timeout  65;
> 
> # ----local
> server {
>     listen       80;
>     server_name  localhost;
>     root     /mnt-nginx/d3;
>     index  index.html index.htm;
>     auth_basic "Restricted";
>     auth_basic_user_file /etc/nginx/13/.htpasswd;
>                         ##### 13 insted of require
>         }
> 
> #---------open-------------------------mydns
>     server {
>         listen       80;
>         server_name  a.mydns.jp;
>         root   /mnt-nginx/d1;
>         index  index.html index.htm;
>            }
> 
> #---------basic auth-----------------------ddns
>     server {
>     listen       80;
>     server_name  s.sun.ddns.vc;
>     root     /mnt-nginx/htdocs/Fam;
>     index  index.html index.htm;
>     auth_basic "Restricted";
>     auth_basic_user_file /etc/nginx/1/.htpasswd;
>                         ##### 1 insted of require
>       }
> }
> ---
> tuyosi
> 

Hiya,

basic_auth is available by default in nginx on OpenBSD.
You do not need to compile it with any special flags/settings.

Thus you can set your PACKAGE_PATH to a mirror near you and simply do

# pkg_add nginx

or if you really want to compile it (why?) you can build it from ports

$ cd /usr/ports/www/nginx
$ make
$ sudo make install

See http://www.openbsd.org/faq/faq15.html for the documentation of the
package and ports system.


Be aware that nginx on OpenBSD runs in a proper chroot under /var/www,
thus you need to create the directories

/var/www/etc/nginx/1
  and
/var/www/etc/nginx/13

and put your .htpasswd files there if you want to use your configuration
as quoted above.  Otherwise you will get errors like

*1 open() "/etc/nginx/conf/13/.htpasswd" failed (2: No such file or
directory)

in /var/www/logs/error.log

The same goes for the document roots. You will need the directories
/var/www/mnt-nginx/d1
/var/www/mnt-nginx/d3
/var/www/mnt-nginx/htdocs/Fam
for your unaltered configuration to work.

Note that basic_auth over unencrypted http might be a weak
authentication mechanism for your purpose.

Also note that the nginx-package does not bring you the htpasswd program
to generate your .htaccess files.
htpasswd is in the OpenBSD base system since OpenBSD 5.6

HTH
rru

Reply via email to