Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown directive "google" #149

Closed
machsix opened this issue Oct 12, 2018 · 6 comments

Comments

Projects
None yet
6 participants
@machsix
Copy link

commented Oct 12, 2018

System:
CentOS 7
Kernel version:
Linux host.localdomain 4.18.13-1.el7.elrepo.x86_64 #1 SMP Wed Oct 10 15:37:55 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
Nginx version:
1.14.0 and 1.15.5
Steps of Compiling

129   mkdir -p ${wwwroot_dir} ${wwwlogs_dir}                                                                                                                                                                      
130   yum install -y httpd-devel pcre perl pcre-devel zlib zlib-devel openssl-devel                                                                                                                               
132   wget http://nginx.org/download/nginx-${nginx_ver}.tar.gz                                                                                                                                                    
133   tar xzf nginx-${nginx_ver}.tar.gz                                                                                                                                                                           
134   cd nginx-${nginx_ver}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
143   # download modules                                                                                                                                                                                          
144   mkdir -p module                                                                                                                                                                                             
145   cd module                                                                                                                                                                                                   
146   git clone https://github.com/cuber/ngx_http_google_filter_module                                                                                                                                            
147   git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module                                                                                                                                                                                                                                                       
148   cd ..                                                                                                                                                                                                       
149                                                                                                                                                                                                               
150   mod_dir=$(pwd)/module                                                                                                                                                                                       
151   [ ! -d "${nginx_install_dir}" ] && mkdir -p ${nginx_install_dir}                                                                                                                                            
152   ./configure --prefix=${nginx_install_dir} \                                                                                                                                                                 
153               --sbin-path=/usr/sbin/nginx \                                                                                                                                                                   
154               --user=${run_user} \                                                                                                                                                                            
155               --group=${run_user} \                                                                                                                                                                           
156               --with-http_stub_status_module \                                                                                                                                                                
157               --with-http_v2_module \                                                                                                                                                                         
158               --with-http_ssl_module \                                                                                                                                                                        
159               --with-http_gzip_static_module \                                                                                                                                                                
160               --with-http_realip_module \                                                                                                                                                                     
161               --with-http_flv_module \                                                                                                                                                                        
162               --with-http_dav_module \                                                                                                                                                                        
163               --with-http_mp4_module \                                                                                                                                                                        
164               --with-mail \                                                                                                                                                                                   
165               --with-mail_ssl_module\                                                                                                                                                                         
166               --with-pcre-jit \                                                                                                                                                                               
167               --add-module=${mod_dir}/ngx_http_google_filter_module \                                                                                                                                         
168               --add-module=${mod_dir}/ngx_http_substitutions_filter_module | tee $current_d/nginx_config.log                                                                                                  
169                                                                                                                                                                                                               
170   make -j 4                                                                                                                                                                                                   
171   make install | tee $current_d/nginx_install.log              

Part of configure log

106 checking for getaddrinfo() ... found                                                                                                                                                                          
107 configuring additional modules                                                                                                                                                                                
108 adding module in /root/Downloads/nginx-1.14.0/module/ngx_http_google_filter_module                                                                                                                            
109  + ngx_http_google_filter_module was configured                                                                                                                                                               
110 adding module in /root/Downloads/nginx-1.14.0/module/ngx_http_substitutions_filter_module                                                                                                                     
111  + ngx_http_subs_filter_module was configured                                                                                                                                                                 
112 checking for PCRE library ... found                                                                                                                                                                           
113 checking for PCRE JIT support ... found                                                                                                                                                                       
114 checking for OpenSSL library ... found                                                                                                                                                                        
115 checking for zlib library ... found                                                                                                                                                                           
116 creating objs/Makefile       

Part of building log

cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g   -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/mail \
        -o objs/addon/src/ngx_http_google_filter_module.o \
        /root/Downloads/nginx-1.14.0/module/ngx_http_google_filter_module/src/ngx_http_google_filter_module.c

After install

[root@host tools]# which nginx
/usr/sbin/nginx
[root@host tools]# nginx -V
nginx version: nginx/1.14.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_dav_module --with-http_mp4_module --with-mail --with-mail_ssl_module --with-pcre-jit --add-module=/root/Downloads/nginx-1.14.0/module/ngx_http_google_filter_module --add-module=/root/Downloads/nginx-1.14.0/module/ngx_http_substitutions_filter_module
[root@host tools]# nginx -t
nginx: [emerg] unknown directive "google" in /usr/local/nginx/conf/vhost/g.mach6.net.conf:39
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

Nignix settings
g.mach6.net.conf

server {
  listen 80;
  server_name g.mach6.net;
  location / {
      return   301 https://$server_name$request_uri;
  }
}
server {
   #listen 80;
   listen 443 ssl http2;
   ssl_certificate /usr/local/nginx/conf/ssl/machx.net.crt;
   ssl_certificate_key /usr/local/nginx/conf/ssl/machx.net.key;
   ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
   ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
   ssl_prefer_server_ciphers on;
   ssl_session_timeout 10m;
   ssl_session_cache builtin:1000 shared:SSL:10m;
   ssl_buffer_size 1400;
   add_header Strict-Transport-Security max-age=15768000;
   ssl_stapling on;
   ssl_stapling_verify on;
   server_name g.mach6.net;
   if ($ssl_protocol = "") { return 301 https://$host$request_uri;}
 
   resolver 8.8.8.8;
   
   if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot") 
   { 
        return 403; 
   }
   
   location / {
       google on;
       google_scholar on;
       google_language en;
   }
   
}

Summary
It seems the module was built with nginx successfully but it just doesn't work.. any idea?

@17huiwei

This comment has been minimized.

Copy link

commented Oct 20, 2018

i've the same problem (after 201809?).

something wrong with recent changes??

@xiaohuid

This comment has been minimized.

Copy link

commented Oct 24, 2018

You can revert recent changes, works well.

git checkout 77532b9

@MkAnaio

This comment has been minimized.

Copy link

commented Oct 30, 2018

Don't git clone, just revise the code in your file directly.
It could work well with current config.

@cuber

This comment has been minimized.

Copy link
Owner

commented Nov 16, 2018

Commit d7bb814 import this problem, ngx_module_type should be HTTP_FILTER, this module must be configured after ngx_http_core_module.
Because the dynamic so feature is introduced after 1.9.11, so the travis has passed.
Please try the dev branch, i have test and update the travis file

@machsix

This comment has been minimized.

Copy link
Author

commented Nov 27, 2018

Commit d7bb814 import this problem, ngx_module_type should be HTTP_FILTER, this module must be configured after ngx_http_core_module.
Because the dynamic so feature is introduced after 1.9.11, so the travis has passed.
Please try the dev branch, i have test and update the travis file

Sorry for the late reply. I tested with nginx 1.14.1 and commit 6edf97c. It works without problem. Thanks for your hard work!

@machsix machsix closed this Nov 27, 2018

@pnjgyl

This comment has been minimized.

Copy link

commented Jan 24, 2019

Commit d7bb814 import this problem, ngx_module_type should be HTTP_FILTER, this module must be configured after ngx_http_core_module.
Because the dynamic so feature is introduced after 1.9.11, so the travis has passed.
Please try the dev branch, i have test and update the travis file

Sorry for the late reply. I tested with nginx 1.14.1 and commit 6edf97c. It works without problem. Thanks for your hard work!

Thank you very much! I meet the same problem with nginx 1.14.2. Then I use nginx 1.14.1 and commit 6edf97c. It works too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.