I am using nginx proxy to nuxt project, and I set real addr in nginx config, here is my config:
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-User-Agent $http_user_agent;
proxy_set_header X-Referer $http_referer;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:3000/;
proxy_redirect off;
},
I found when nuxt project axios a request to tomcat ,tomcat log get X-Real-IP is null,I think the problem is that the axios didn't give the nginx header to tomcat,so I prepare to get nginx header in nuxt and set axios header so that tomcat can get X-Real-IP. So the problem is how to get request header using nuxt ! Any one can help ?
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1330">#c1330</a>)</em></sub></div>