I have installed nginx and made follow host:
server {
listen 80; # Listen on port 80 for IPv4 requests
server_name jenkins.mydomain.ru;
root /var/lib/jenkins;
access_log /var/log/nginx/jenkins_access.log;
error_log /var/log/nginx/jenkins_error.log;
location / {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/passwd/htpasswd;
proxy_pass http://127.0.0.1:8080/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_max_temp_file_size 0;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
# Optional configuration to detect and redirect iPhones
if ($http_user_agent ~* '(iPhone|iPod)') {
rewrite ^/$ /view/iphone/ redirect;
}
}
}
After that I can access to Jenkinks in jenkins.mydomain.ru and it's require password.
But I still can access to Jenkinks in http://mydomain.ru:8080/ without any password.
How can I disallow access to Jenkinks in http://mydomain.ru:8080/?
Best Answer
Jenkins seems to be listening on port 8080, so nginx has no control over it -- you need to go to jenkins' config file and tell it to listen on 127.0.0.1 (local connections only), where I would guess that it's currently set to 0.0.0.0 (open to all)