nginx多站点配置问题
2017-09-04 14:35
239 查看
在nginx的conf文件夹中创建一个vhost的文件夹
每个站点都可以配置一个conf的配置文件文件内容具体如下
server{ listen 80; server_name xxx.example.com; root /data/www/xxx; //网页页面的位置地址 index index.php index.html index.htm; location /api/ { proxy_set_header Host $host; proxy_set_header Host $host; proxy_set_header X-Real-Ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://simlergray.cn:8080; //配置反向代理 } }
nginx.conf 配置
user nobody; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { 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 /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; client_max_body_size 6M; client_body_buffer_size 128K; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. #include /etc/nginx/conf.d/*.conf; # server { #listen 80 default_server; #listen [::]:80 default_server; #server_name _; #root /usr/share/nginx/html; # Load configuration files for the default server block. #include /etc/nginx/default.d/*.conf; # listen 80; # server_name localhost; # location / { # root /data/www/index; # index index.html index.htm; # } #error_page 404 /404.html; # location = /40x.html { #} #error_page 500 502 503 504 /50x.html; # location = /50x.html { #} # } include vhost/*.conf; }
配置完之后 还有最后一步,就是配置域名的解析,每一个二级域名都去绑定本服务器的ip地址,这是很重要的一个步骤,新手很容易忘记这一步,或者不知道这一步,很容易出现明明配置好了 nginx为什么无法请求成功的问题
相关文章推荐
- Ubuntu14.04 下安装配置php5和nginx问题解决
- 使用nginx配置android文档本地站点
- Nginx配置CI框架问题(Linux平台下Centos系统)
- Nginx+Keepalive实现高可用+负载均衡并配置多web站点(两台服务器)
- CentOS 下 nginx + keepalived 配置高可用暨双机Web站点
- Nginx配置proxy_pass 转发问题
- dpkg: 依赖关系问题使得 nginx 的配置工作不能继续
- Laravel Nginx 站点配置文件(Homestead)
- Wordpress3.9开启多站点配置配置nginx进行局域网测试.
- 利用不同端口为本地nginx服务器配置多个站点
- nginx下配置多站点
- 在一个nginx服务器上配置多个访问站点的方法
- nginx配置tomcat https websockets等问题汇总解决方式
- Nginx 配置静态文件404问题
- centos7下配置nginx的mongodb驱动问题
- Nginx配置的问题
- nginx过滤url实现前台js的配置问题
- nginx php-fpm内存配置问题
- Nginx 配置静态文件404问题
- 什么是ssl证书,什么是https,nginx如何配置ssl证书,兼容https与http同时访问站点