如果既想匹配'/'进行反向代理,同时又想通过nginx提供网站首页,可以在server中进行如下配置:

 user  python; # 运行Nginx的用户
worker_processes auto; # 根据经验,一般为处理器核数的1-2倍
error_log logs/error.log notice; #相对于/usr/local/nginx这个路径, debug info notice warn error crit几种级别
pid logs/nginx.pid; events {
use epoll; # linux平台
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;
tcp_nodelay on;
keepalive_timeout 65; server {
server_name localhost www.xxx.top;
listen 80;
listen 443 ssl; # http和https均可以访问
root /usr/local/nginx/html; # 全局定义默认根目录
index index.html index.htm; # 全局定义默认首页地址
ssl_certificate cert/server.crt;# 证书路径,相对/usr/local/nginx/conf路径
ssl_certificate_key cert/server.key;# 私钥路径
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
charset utf-8;
access_log logs/host.access.log main;
error_log logs/host.error.log error; #静态文件访问
location /static {
# 注意使用alias,而非root,如果使用root,则变成了访问/home/python/static/static/下的静态文件
alias /home/python/static;
if ($query_string){
expires max;
}
} #网站图标
location = /favicon.ico {
access_log off;
root /home/python/static/; # 网站图标位置/home/python/static/favicon.ico
} location = / {
index index.html index.htm;# 会重新访问/index.html
} location = /index.html {
root html;#html是相对于nginx安装目录的一个相对路径,会直接打开html/index.html,并返回该页面
} location / {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8000;
} #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;
}
}

nginx提供网站首页的一个实例的更多相关文章

  1. windows使用nginx实现网站负载均衡测试实例

    如果你关注过nginx,必定知道nginx这个软件有什么用的,如果你的网站访问量越来越高,一台服务器已经没有办法承受流量压力,那就增多几台服务器来做负载吧.做网站负载可以买硬件设备来实现,比如F5,不 ...

  2. PHP.5-DIV+CSS布局网站首页实例

    DIV+CSS布局网站首页实例 网站页面布局 http://www.sj33.cn/digital/wyll/201501/42379.html[页头.页脚.侧边栏和内容区域] #避免各浏览器对CSS ...

  3. 【URLOS应用开发基础】10分钟制作一个nginx静态网站环境应用

    URLOS开发者功能已上线有一段时间了,目前通过部分开发者的使用体验来看,不得不说URLOS在服务器软件开发效率方面确实有着得天独厚的优势,凭借docker容器技术与其良好的应用生态环境,URLOS必 ...

  4. 在IIS上发布一个WebService,再发布一个网站调用这个WebService(实例)

    首先描述一下先决条件:IIS可用,VS2005可用. 好,现在开始: 首先写一个WebService并把它发布到IIS上: 在IIS上的默认网站下新建一个“虚拟目录”,取名为“webservice1” ...

  5. 用HTML+CSS编写一个计科院网站首页的静态网页

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. 使用nginx部署网站

    前面的话 如果服务器只需要放置一个网站程序,解析网站到服务器的网站,网站程序监听80端口就可以了.如果服务器有很多应用,借助nginx不仅可以实现端口的代理,还可以实现负载均衡.本文将详细介绍前端及n ...

  7. Nginx——使用 Nginx 提升网站访问速度【转载+整理】

    原文地址 本文是写于 2008 年,文中提到 Nginx 不支持 Windows 操作系统,但是现在它已经支持了,此外还支持 FreeBSD,Solaris,MacOS X~ Nginx(" ...

  8. 使用 Nginx 提升网站访问速度

    使用 Nginx 提升网站访问速度 http://www.ibm.com/developerworks/cn/web/wa-lo-nginx/ Nginx 简介 Nginx ("engine ...

  9. 使用 Nginx 提升网站访问速度(转)

    Nginx 简介 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx 是由 Ig ...

随机推荐

  1. how to input special symbol in macOS

    how to input special symbol in macOS 如何在 macOS 中输入特殊符号 1024 ≈ 1000 2^10 == 1024 约等于 1000, 方便用来表示 Opt ...

  2. How to Use RSS on Your Website

    RSS feed 1 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...

  3. Mapbox 地图实验室

    Mapbox 地图实验室 Learn with Mapbox https://www.mapbox.com/community/education/ https://labs.mapbox.com/e ...

  4. DRM & 音视频 & 防盗链

    DRM & 音视频 & 防盗链 DRM Digital Rights Management / 数字版权管理 https://en.wikipedia.org/wiki/Digital ...

  5. 为什么10月上线的NGK Global即将燎原资本市场

    近日据社区透露,NGK Global将在10月全面启动,数据公开透明,人人可以参与运营监管. 现在,区块链经济已经处于爆发前夜.金融行业的探索领先一筹,而其他行业的应用正在快速展开.区块链行业应用头部 ...

  6. 【PY从0到1】 一文掌握Pandas量化进阶

    # 一文掌握Pandas量化进阶 # 这节课学习Pandas更深的内容. # 导入库: import numpy as np import pandas as pd # 制作DataFrame np. ...

  7. 04_Mysql配置文件(重要参数)

    Mysql配置文件(重要参数) mysql配置文件的内容 打开my.ini文件(ProgramData默认隐藏,需取消隐藏) 绿色文字为注解,并不会被加载执行 删除注解,只保留重要有用的

  8. 020_CSS3

    目录 如何学习CSS 什么是CSS 发展史 快速入门 css的优势 三种CSS导入方式 拓展:外部样式两种写法 选择器 基本选择器 层次选择器 结构伪类选择器 属性选择器 美化网页元素 为什么要美化网 ...

  9. spring学习路径

    1.https://zhuanlan.zhihu.com/p/72581899 spring 要点记录: (1)Web服务器的作用说穿了就是:将某个主机上的资源映射为一个URL供外界访问. (2)通过 ...

  10. Gradle 差异化构建

    Compile 默认的依赖方式,任何情况下都会依赖. Provided 只提供编译时依赖,打包时不会添加进去. Apk 只在打包Apk包时依赖,这个应该是比较少用到的. TestCompile 只在测 ...