Configuration on nginx not working
dynamiccontent opened this issue · 2 comments
I am wondering what I am doing wrong.
Do you actually need php, go installed if you don't build from source?
I just want to generate and serve the html files via nginx (daily reports) so I can view them via browser. It should be simple right?
The main thing I don't understand how do you actually serve report files from /usr/share/nginx/html.
I have run the ./dmarc-report-converter.sh and I see the files are generated in the /tmp/dmarc_files and /tmp/html folder.
A working sample nginx config and config.yaml would be super helpful to get up and running quickly... I am probably doing something really silly...
/etc/nginx/conf.d/dmarc.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name dmarc.example.com;
ssl_certificate /etc/ssl/certs/cert.crt;
ssl_certificate_key /etc/ssl/certs/cert.key;
location /dmarc/ {
root /usr/share/nginx/html;
autoindex on;
autoindex_localtime on;
}
}
/opt/dmarc-report-converter/config.yaml
input:
delete: no
dir: "/tmp/dmarc_files/"
imap:
server: "mail.example.com:993"
username: "dmarc@example.com"
password: "pass"
mailbox: "inbox"
debug: no
delete: no
output:
file: "/tmp/html/{{ .ID }}.html"
format: "html"
assets_path: "/dmarc/assets"
lookup_addr: no
merge_reports: no
log_debug: no
log_datetime: no
from /var/log/nginx/error.log looks like my paths are just wrong...
do you need to configure index in nginx config too?
2022/11/14 21:40:53 [error] 2057#2057: *1 open() "/etc/nginx/html/dmarc" failed (2: No such file or directory), client: 1.2.3.4, server: dmarc.example.com, request: "GET /dmarc HTTP/2.0", host: "dmarc.example.com"
Hi @dynamiccontent !
Do you actually need php, go installed if you don't build from source?
dmarc-report-converter has no dependency on php, it generates static html files based on builtin or provided external templates.
The main thing I don't understand how do you actually serve report files from /usr/share/nginx/html.
It's simple, in that case, the output.file
option in configuration file should be adjusted with your root
path in nginx config, for example:
output:
file: "/usr/share/nginx/html/dmarc/{{ .TodayID }}.html"
and
location /dmarc/ {
root /usr/share/nginx/html;
autoindex on;
autoindex_localtime on;
}
I use similar setup and it works well. List of reports will be available at "https://dmarc.example.com/dmarc/" (according to server_name
).
In addition, I can recommend to set output.format
to html_static
, it's a little easier to use.
A working sample nginx config and config.yaml would be super helpful to get up and running quickly
Yes, you are right, maybe I should adjust example config.dist.yaml
with nginx example in README.
If you have more questions, feel free to ask.
My mistake on the configuration. Now it's working. Thanks for the help @tierpod
For exchange 2019 for IMAP for mailbox: "inbox" je need to specify the name of the folder it did not work when I specified mailbox name or display name.
Also maybe a small thing also there is a 404 error for https://dmarc.example.com/favicon.ico not a big deal we could add this to assets folder if we want to put our own favicon.ico in there so we don't pollute the /usr/share/nginx/html/dmarc/ folder with favicon. Right now the default path to favicon.ico is in the reports folder.
Here is my working configuration example:
Have also done https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/ so it's not exposed even if it's just inside the company network.
/etc/nginx/conf.d/dmarc.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name dmarc.example.com;
root /usr/share/nginx/html/dmarc/;
ssl_certificate /etc/ssl/certs/cert.crt;
ssl_certificate_key /etc/ssl/certs/key.key;
auth_basic "Admin login";
auth_basic_user_file /etc/apache2/.htpasswd;
rewrite ^/$ /dmarc/ permanent;
location /dmarc/ {
root /usr/share/nginx/html;
autoindex on;
autoindex_localtime on;
}
location /assets/ {
root /usr/share/nginx/html;
}
}
/opt/dmarc-report-converter/config.yaml
input:
delete: no
dir: "/tmp/dmarc_files/"
imap:
server: "mail.example.com:993"
username: "dmarc@example.com"
password: "pass"
mailbox: "inbox"
debug: no
delete: no
output:
file: "/usr/share/nginx/html/dmarc/{{ .TodayID }}.html"
format: "html"
assets_path: "/assets"
lookup_addr: yes
merge_reports: yes
log_debug: no
log_datetime: no