码迷,mamicode.com
首页 > 其他好文 > 详细

nginx反向代理服务器域名解析配置实操

时间:2018-01-23 15:51:56      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:hosts   red   logs   return   dir   重启nginx   php   ignore   www.   

1、进入nginx目录cd conf:创建文件夹

sudo mkdir vhost,cd vhost,sudo vim www.fanxing.store.conf,添加如下内容

server {
default_type ‘text/html‘;
charset utf-8;
listen 80;
autoindex on;
server_name www.fanxing.store;
access_log /usr/local/nginx/logs/access.log combined;
index index.html index.htm index.jsp index.php;
#error_page 404 /404.html;
if ( $query_string ~* ".*[\;‘\<\>].*" ){
return 404;
}
location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
deny all;
}
location / {
#root /product/ftpfile/learning/;

proxy_pass http://127.0.0.1:8080; //暂时跳到tomcat
add_header Access-Control-Allow-Origin *;
}
}

保存

2.重启nginx:sudo ../../sbin/nginx -s rload

3.配置文件服务器

server {
listen 80;
autoindex off;
server_name image.fanxing.store;
access_log /usr/local/nginx/logs/access.log combined;
index index.html index.htm index.jsp index.php;
#error_page 404 /404.html;
if ( $query_string ~* ".*[\;‘\<\>].*" ){
return 404;
}
location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
deny all;
}
location / {
root /ftpfile/;
add_header Access-Control-Allow-Origin *;
}
}

*****出现404Not Found:image.fanxing.store末尾未加.conf,如果未配置,默认加载nginx/下的nginx.conf

(nginx: [warn] conflicting server name "image.fanxing.store" on 0.0.0.0:80, ignored,)

nginx -s reload

重启nginx报错。

[warn]: conflicting server name “domain.com” on 0.0.0.0:80, ignored

检查:server/nginx-1.4.7/conf/vhosts 下的配置文件,应该有重复绑定域名的,找到,修改或删除即可。

如果image.fanxing.store.conf:autoindex off;就无法访问目录结构,出现403forbidden错误,不可访问;

*******

 

nginx反向代理服务器域名解析配置实操

标签:hosts   red   logs   return   dir   重启nginx   php   ignore   www.   

原文地址:https://www.cnblogs.com/coolcold/p/8335632.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!