Reputation:
My website always open in path localhost, but my server_name have other domen name. How i can fix it ? My configuration
https://i.sstatic.net/MXm5k.jpg
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name mydomain;
#charset koi8-r;
access_log logs/host.access.log;
location / {
proxy_pass http://127.0.0.1:3037;
}
}
}
Upvotes: 6
Views: 15583
Reputation: 11
solution: add bad urls to "/etc/hosts" like this: enter image description here
Upvotes: 0
Reputation: 21
You have to match your custom domain name to your machine's local IP address. This can be done using the default 127.0.0.1 or by typing the command, "ip addr" in your Ubuntu terminal. this command will list out two IP addresses offered by you machine. You can match any of the IP addresses to your custom domain in the "/etc/hosts" file.
Upvotes: 0
Reputation: 21
If you are using Ubuntu you also have to define in /etc/hosts
your server name for you local ip:
127.0.0.1 mydomain www.mydomain.com mydomain.com
Upvotes: 0
Reputation: 26885
For testing and accepting doing a "catch-all", you can use server_name _
From: http://nginx.org/en/docs/http/server_names.html
In catch-all server examples the strange name “_” can be seen:
server {
listen 80 default_server;
server_name _;
return 444;
}
Upvotes: 2
Reputation: 146490
Change your config to below
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
server {
listen 80 default_server;
return 403;
}
server {
listen 80;
server_name mydomain;
#charset koi8-r;
access_log logs/host.access.log;
location / {
proxy_pass http://127.0.0.1:3037;
}
}
}
First server block is the default server nginx will serve the request from if no virtual host matches. So you need to have 2 blocks in case you only want specific server_name
to be allowed and rest all to be denied
Upvotes: 5