如何配置nginx不显示登录控制台?

时间:2018-08-11 15:53:12

标签: nginx logging vue.js console console.log

我在生产中有一个Web应用程序(使用Vuejs),并使用nginx作为代理。我不想在浏览器控制台中显示日志。我尝试:

  server {   

  listen 80 default_server;   
  listen [::]:80 default_server;

  access_log  /dev/null;   
  error_log /dev/null;

  access_log  off;   
  error_log off;

  root /usr/share/nginx/html;

  index index.html;

  server_name you.server.com;

  location / {
    try_files $uri $uri/ @rewrites;   }

  location @rewrites {
    rewrite ^(.+)$ /index.html last;   }

  location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    # Some basic cache-control for static files to be sent to the browser
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";   }

}

1 个答案:

答案 0 :(得分:0)

Nginx无法控制向浏览器控制台的输出!

只需从代码中删除控制台日志。

仅供参考:如果您愿意

  // make sure to set this synchronously immediately after loading Vue
  Vue.config.devtools = false;
  // make sure to set this synchronously immediately after loading Vue
  Vue.config.devtools = false;