Not able to find /etc/nginx/sites-enabled/default
Solution 1
/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
Solution 2
You can use the proxy module in Nginx. Something like this should work:
server {
listen *:80;
server_name yourserver.com;
location / {
proxy_pass http://127.0.0.1:8080;
include proxy_params
}
}
https://stackoverflow.com/questions/12847771/configure-nginx-with-proxy-pass
Solution 3
You should start with checking compiled-in settings for nginx with nginx -V. It should point you to main configuration file, --conf-path= flag.
All other files should be included with "include" directive in nginx. If you want you can add server {} directive to main configuration file.
Related videos on Youtube
![xrcwrn](https://i.stack.imgur.com/yQ49v.png?s=256&g=1)
xrcwrn
Updated on September 18, 2022Comments
-
xrcwrn almost 2 years
I have installed Nginx server at my cloud space checked by ip it is showing proper page. Now I have also a apache Tomcat8 on port
8080
I want to redirect my port80
traffic to8080
for that I am following this tutorial http://www.mkyong.com/nginx/nginx-apache-tomcat-configuration-example/ My problem is I am not getting the path/etc/nginx/sites-enabled/default
I am checing my tomcat application with IP address How to add nxg config detail
-
xrcwrn almost 9 yearson which file I will write above content as in mentioned tutorial It is givent to write content in
/etc/nginx/sites-enabled/default
but I am not getting file I dont havesites-enabled
folder. I am only Ip address -
xrcwrn almost 9 years
server_name yourdomain.com;
should be likeserver_name abcc.com;
orserver_name www.abcd.com;
-
xrcwrn almost 9 yearsdone this step onening browser is not redirection to tomcat
-
xrcwrn almost 9 yearsdone above but it is not redirecting to tomcat
-
hookenz almost 9 years@xrcwrn - Is tomcat listening on 127.0.0.1 port 8080 or an macine IP port 8080 ? If it's listening on your local machine IP, then that is why it's not working. Change it to listen on 127.0.0.1
-
hookenz almost 9 yearsVerify tomcat works first. point your browser at 127.0.0.1:8080, If it doesn't come up, don't blame it on nginx.