W
W
WebDev2017-09-18 15:08:40
Nginx
WebDev, 2017-09-18 15:08:40

How to write logs of visits to the site?

There is an html page that is embedded on other sites through an iframe. It is necessary to collect information about which sites this page was requested from. How can this be done without a server-side API?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
John Doe, 2017-09-18
@rabbit418

If you need simple statistics, then the usual access log is also suitable:

server {
  listen 80;
  server_name example.com;

  # Logs
  access_log /var/log/nginx/access.log;
}

After that, the log file can be parsed very easily. For example, to display the statistics of response codes, you can run in the terminal:
or do the same but using awk:
You can also see the most requested page:
awk -F\" '{print $2}' access.log | awk '{print $2}' | sort | uniq -c | sort -r

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question