website is loading page not found error via nginx - nginx

We have setup a nginx server with the following configuration but when trying to access the domain it is giving the . Nginx is installed on debian 10 machine
Error 404: Not found :-(
THe web server is not configured to handle this request. Are you sure you typed in the correct URL?. If yes, please contact the admin.
Following is the configuration of the nginx file
server {
listen 80;
server_name domain_name ;
root /var/www;
}
Permissions for /var/www is set correctly. Still not able to acecss the domain name . Please help here

Related

nginx: 502 bad gateway if /index.html is not in URL

i don't understand what i'm doing wrong so i hope somebody can help :)
When i access http://10.0.0.54/index.html i get the right page but if i try to access http://10.0.0.54 instead of showing the index file it redirects me to https://10.0.0.54 showing error 502 bad gateway.
This is the configuration /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/salvaderi;
index index.html;
server_name _;
location ~ /.well-known/acme-challenge {
allow all;
root /var/www/html/salvaderi;
}
location / {
root /var/www/html/salvaderi;
index index.html;
}
}
I am running nginx 1.18.0 on ubuntu 22.04
i tried changing parameters inside location /{} but i always get the same result. I also changed the root directory and made sure permission where set right. Searching on for the solution i saw other people having problems about PHP and FastCGI but i am not using it.
Your configuration about to be right.
Possible there is some kind of proxy or load-balancer is placed between you and nginx you configuring since you got redirect to HTTPS whether there is no any redirection instructions in your config and, in the same time, there is no listen 443 ssl in config, but you still got response on HTTPS request.
I'd check next:
Is 10.0.0.54 in fact IP of your server?
Is there any return 301, return 302 or rewrite instructions in your nginx config (the better
way is to dump config with nginx -T command and look over).
Didn't
you previously have configured some redirects that may have been
cached by your web client previously? Try to send GET request with
curl instead of web browser (if browser been used for tests).

I am using nginx for project deployement and I am using windows

Can anyone please help me what changes I have to made in conf nginx.conf.
And after making changes, what commands I have to writeon windows for showing 404 page. I have create an html page for 404 condition.
In your nginx/sites-available/default configuration file, you can add the following to your server setup:
server {
listen 80 default_server;
...
...
...
error_page 404 /your_custom_404_page.html;
}

How can i get domain-name instead of ip-address using nginx in ubuntu?

I complete the configuration in nginx as well as i connect it via this link
http://1.2.3.4/MyProject/
where my ip address assign in nginx 1.2.3.4
and my nginx configuration
server_name 1.2.3.4;
listen 80;
but when i give domain name like
server name account.com;
listen 80;
but when i open that page from browser like:- http://account.come it will redirect at http://:1.2.3.4/myproject
so how can i hide my ip-address and see my domain name?
Thankyou so much.
remove any server_name 1.2.3.4; in all config files and also see default config file under site-availeables
to check why its redirect to ip please check yor DNS server for example bind or bind9 service or named: /etc/named and all zones under /var/lib/named
maybe new site not configured proper by you then ping sitename once in your client system like windows and once by lynx on server via putty...
2-check nginx is working with proxycache or module cache ??
3-check your project code setting for example wordpress or some projects redirect some pages to cached url on database...
to check is from this project make test.php and code about echo rand(1,999); that can test redirection and cache at once.
ifrandom code show same number it is cache problem.
if no cache but redirecting to server ip address it is configuration issue...
if not solved remove all http server configs and define again .
add with www alias for site name
server {
listen 80 ;
server_name a.com www.a.com;
I had got the solution for that, I changed my godady account configuration.
and then put like:-
server_name abc.com;

Nginx does not serve the flask pages and shows the default static page

I have a flask app running with gunicorn and nginx on Ubuntu 14.04 using AWS EC2. I have deleted default site from /etc/nginx/sites-available and /etc/nginx/sites-enabled. In those two folders, there is only one file: flasky - my nginx file as below:
server {
listen 80;
location / {
include proxy_params;
proxy_pass http://unix:/tmp/flasky.sock;
}
When I enter the IP of the server in the browser, the default Nginx static page shows up. If I go to /auth/login, the correct page served by Flask shows up properly.
If the change the port from 80 to 8080, restart Nginx, enter http://ip-address:8080 then all Flask pages work well. I don't know how to fix this for port 80. Please help! Thanks!
UPDATE: I just found out that if I use the AWS Public DNS: http://ec2-50-112-125-180.us-west-2.compute.amazonaws.com, it works. But if I use the corresponding Elastic IP: 50.112.125.180 it shows the nginx default page. Anyone knows why?
Search your nginx.conf for the word include
maybe it's including other directories for config files.
Also, there may be other config blocks with
location /
that is superseding this section that also have listen 80.

Wordpress site url missing www prefix after installation under nginx server

I am in the process of migrating my wordpress, website www.programminginc.net, which is presently running on a shared hosting site, to a VPS Server with nginx Server. I have selected an Ubuntu 12.04.3 LTS server for my VPS hosting.
I could complete almost all jobs with the help of EasyEngine script and was successful in installing my website. After installation, my wordpress site URL was missing the www prefix. It was installed with the url [http://programminginc.net] not with [http://www.programminginc.net].
So, I changed the wordpress in dashboard general setting the WordPress Address (URL)
and Site Address (URL) [http://programminginc.net] to [http://www.programminginc.net]. After this change my website stopped working.
Can you help me figure out where the error is and how can I correct it? Is it the problem with wordpress or nginx itself? Thanks in advance.
Could be the configuration for nginx, make sure it is handling the request for www.example.com and make sure that there is an A record present for www
EasyEngine bydefault removed http:// https:// and www from the url and make website accessible via example.com and www.example.com
To make non-www to www you need to change the following file:
vim /etc/nginx/sites-available/example.com
# WPSINGLE BASIC NGINX CONFIGURATION
server {
server_name example.com www.example.com;
Replace above code with following lines
# WPSINGLE BASIC NGINX CONFIGURATION
server {
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
server {
server_name www.example.com;
Track this issue on github easyengine page: https://github.com/rtCamp/easyengine/issues/71

Resources