Welcome! Log In Create A New Profile

Advanced

nginx.conf

Posted by xstation 
xstation
nginx.conf
December 16, 2016 07:00AM
eneted this in the conf file under http

SetEnvIfNoCase User-Agent "^Baiduspider" block_bot
Order Allow,Deny
Allow from All
Deny from env=block_bot


but on restart got a error message

Job for nginx.service failed. See 'systemctl status nginx.service' and
'journalctl -xn' for details.
[email protected]:~#

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271581#msg-271581

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
c0nw0nk
Re: nginx.conf
December 16, 2016 07:10AM
xstation Wrote:
-------------------------------------------------------
> eneted this in the conf file under http
>
> SetEnvIfNoCase User-Agent "^Baiduspider" block_bot
> Order Allow,Deny
> Allow from All
> Deny from env=block_bot
>
>
> but on restart got a error message
>
> Job for nginx.service failed. See 'systemctl status nginx.service' and
> 'journalctl -xn' for details.
> [email protected]:~#

That is an config for Apache web server on Nginx you want to do this. Put
inside location {} or server {}

if ($http_user_agent ~ "^Baiduspider") {
return 403;
}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271582#msg-271582

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
xstation
Re: nginx.conf
December 16, 2016 07:20AM
thanks for fast reply#
here is what I get

[email protected]:~# nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] "if" directive is not allowed here in
/etc/nginx/nginx.conf:82
nginx: configuration file /etc/nginx/nginx.conf test failed

so 'if' should be deleted?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271583#msg-271583

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
xstation
Re: nginx.conf
December 16, 2016 07:40AM
If I delete the if!

I get an error

[email protected]:~# nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] unknown directive "($http_user_agent" in
/etc/nginx/nginx.conf:82
nginx: configuration file /etc/nginx/nginx.conf test failed

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271585#msg-271585

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Anonymous User
Re: nginx.conf
December 16, 2016 08:00AM
‎Take a look at this:
http://ask.xmodulo.com/block-specific-user-agents-nginx-web-server.html

Personally, I would use the map feature since eventually there will be other user agents to block.

I use three maps. I block based on requests, referrals, and ‎user agents. The user agent is kind of obvious. Unwanted referrals is a personal thing. I find some websites linking to me that are pure crap like stumbleupon. I don't want their traffic. Yeah sometimes stumbleupon has a relevant link, but most of the time their links make no sense. Some sites will link to your website for SEO. Some linking is just freakin out there, like when Hamas linked to my site. (Humus I like...Hamas not so much. )

Blocking requests is useful if you want to get the IPs of hackers. I find many requests for the directory "backup."‎ I even have the Chinese equivalent to backup in my bad request trap. Rather than let them 404, I 444 them, and then check the IP to see if it goes to a hosting company, VPS, VPN, etc. You can't block enough IPs at the firewall in my opinion.

Every IP you block that isn't an eyeball, even if harmless today, might be harmful in the future. No eyeballs, no need to view the site.


  Original Message  
From: xstation
Sent: Thursday, December 15, 2016 10:35 PM
To: nginx@nginx.org
Reply To: nginx@nginx.org
Subject: Re: nginx.conf

If I delete the if!

I get an error

[email protected]:~# nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] unknown directive "($http_user_agent" in
/etc/nginx/nginx.conf:82
nginx: configuration file /etc/nginx/nginx.conf test failed

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271585#msg-271585

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
c0nw0nk
Re: nginx.conf
December 16, 2016 08:00AM
Provide your full config please.

Also this error log. [emerg] "if" directive is not allowed here
That means you put the code I provided in a invalid area I would assume not
between location {} or server {} tags as I said.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271586#msg-271586

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
xstation
Re: nginx.conf
December 16, 2016 09:50AM
Here is full conf

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {


##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;



##
# SSL Settings
##


ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;

ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json
application/javascript text/xml application/xml application/xml+rss
text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;

($http_user_agent ~ "^Baiduspider") {
return 403;
}

# }
#
# server {
# listen localhost:143;
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;


}

# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271598#msg-271598

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Anonymous User
Re: nginx.conf
December 16, 2016 10:40AM
Are you trying to block baiduspider from your html email? 

I think you should review the commented out lines. Very old school, but you may want to just print your conf file and line up curly braces. Perhaps copy the conf file, delete commented lines, and then see if it makes sense.  It looks to me like the conf file can't be parsed due to mismatches.

  Original Message  
From: xstation
Sent: Friday, December 16, 2016 12:45 AM
To: nginx@nginx.org
Reply To: nginx@nginx.org
Subject: Re: nginx.conf

Here is full conf

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {


##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;



##
# SSL Settings
##


ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;

ssl_prefer_server_ciphers on;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json
application/javascript text/xml application/xml application/xml+rss
text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}


#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;

($http_user_agent ~ "^Baiduspider") {
return 403;
}

# }
#
# server {
# listen localhost:143;
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;


}

# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271598#msg-271598

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
xstation
Re: nginx.conf
December 17, 2016 02:30PM
thanks for your reply

seems to have problems but just have to leave it for time being just comment
out the lines refering to spider etc and hopes it restarts.
many thanks for sugestions try to brush up on my knowledage base

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,271581,271628#msg-271628

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login