/etc/nginx/sites-enabled/default
is the path given to the default website for Debian based systems. They are usually links to files contained /etc/nginx/sites-available
.
/etc/nginx/conf.d
is a path used in most configurations including Debian derivatives like Ubuntu and other distro's like CentOS etc.
/etc/nginx/nginx.conf
is the main configuration file that includes all conf files from one or both of those directories.
You can usually place a configuration file ending in .conf
in /etc/nginx/conf.d
.
So with that knowledge. Create a conf file with a configuration like the following:
So create a file /etc/nginx/conf.d/tomcat.conf
containing a configuration like:
server {
listen 80;
server_name yourdomain.com;
proxy_cache one;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
}
}
Note: the proxy_set_headers
are useful for logging and apps that need to identify the real client. In theory you can extract the X-Forwarded-For
HTTP header to use as the real address for the address of the client in your app or tomcat logs. Otherwise the client will always appear to be the address of the proxy server itself.