nginx配置如下:
nginx.conf:
#user nobody;
worker_processes 2; #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 {
include mime.types;
default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 80;
server_name server8.test.com;
root /var/www/web1; #charset koi8-r; #access_log logs/host.access.log main; location / {
index index.html index.htm;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} } server {
listen 80 default_server;
server_name www8.test.com;
root /var/www/web2;
index index.html index.htm;
access_log /var/log/nginx/www.gmq.com-access.log main;
error_log /var/log/nginx/www.gmq.com-error.log warn;
} }
1、server_name配置的随便写的域名,客户机无法访问问题?
如上,这是我服务器配置的nginx的配置文件,我在客户机上面,怎么访问都不行。郁闷!
解决:
网上很多说设置hosts文件,对,确实是这样解决的,但是没说是设置客户机还是服务器的hosts文件!!坑
我自己解决:
因为是我局域网的,我设置客户机的访问hosts文件,这才正确,日了狗了!!!
如下:
在客户机上设置hosts文件:
增加以下两句话,即可,服务器上的hosts文件不需要设置:
(服务器IP 域名)
192.168.100.189 server8.gmq.com
192.168.100.189 www8.gmq.com
以上解决!!!