Hi,
I create an Azure VM (Ubuntu 16).
I installed Nginx-Naxsi and I got it to work fine. I was able to have redirect to the website I created.
The issue comes when I try to install cerbot using: apt-get install python-certbot-nginx
When installing I get:
nginx[104162]: nginx: [emerg] unknown directive “MainRule” in /etc/nginx/naxsi_core.rules:19
nginx[104162]: nginx: configuration file /etc/nginx/nginx.conf test failed
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result ‘exit-code’.
Error while running nginx -c /etc/nginx/nginx.conf -t.
nginx: [emerg] unknown directive “MainRule” in /etc/nginx/naxsi_core.rules:19
nginx: configuration file /etc/nginx/nginx.conf test failed
The nginx plugin is not working; there may be problems with your existing configuration.
The error was: MisconfigurationError(‘Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] unknown directive “MainRule” in /etc/nginx/naxsi_core.rules:19\nnginx: configuration file /etc/nginx/nginx.conf test failed\n’,)
I have tried to comment out the line 19 in the naxsi_core file, but then it wants to me to comment every line after that.
On another VM I was able to successfully get Certbot working without Naxsi.
Is there a solution so I can have Nginx/Naxsi work with Let’s Encrypt/Certbot?
Yep, that’s how I installed certbot. Then just certbot --nginx. From your nginx -V output it looks like you have to re-./configure nginx with --add-module=<path to naxsi_src> set and run make && make install again (as @stevenzhu pointed out).