nginx提供网站首页的一个实例
如果既想匹配'/'进行反向代理,同时又想通过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提供网站首页的一个实例的更多相关文章
- windows使用nginx实现网站负载均衡测试实例
如果你关注过nginx,必定知道nginx这个软件有什么用的,如果你的网站访问量越来越高,一台服务器已经没有办法承受流量压力,那就增多几台服务器来做负载吧.做网站负载可以买硬件设备来实现,比如F5,不 ...
- PHP.5-DIV+CSS布局网站首页实例
DIV+CSS布局网站首页实例 网站页面布局 http://www.sj33.cn/digital/wyll/201501/42379.html[页头.页脚.侧边栏和内容区域] #避免各浏览器对CSS ...
- 【URLOS应用开发基础】10分钟制作一个nginx静态网站环境应用
URLOS开发者功能已上线有一段时间了,目前通过部分开发者的使用体验来看,不得不说URLOS在服务器软件开发效率方面确实有着得天独厚的优势,凭借docker容器技术与其良好的应用生态环境,URLOS必 ...
- 在IIS上发布一个WebService,再发布一个网站调用这个WebService(实例)
首先描述一下先决条件:IIS可用,VS2005可用. 好,现在开始: 首先写一个WebService并把它发布到IIS上: 在IIS上的默认网站下新建一个“虚拟目录”,取名为“webservice1” ...
- 用HTML+CSS编写一个计科院网站首页的静态网页
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 使用nginx部署网站
前面的话 如果服务器只需要放置一个网站程序,解析网站到服务器的网站,网站程序监听80端口就可以了.如果服务器有很多应用,借助nginx不仅可以实现端口的代理,还可以实现负载均衡.本文将详细介绍前端及n ...
- Nginx——使用 Nginx 提升网站访问速度【转载+整理】
原文地址 本文是写于 2008 年,文中提到 Nginx 不支持 Windows 操作系统,但是现在它已经支持了,此外还支持 FreeBSD,Solaris,MacOS X~ Nginx(" ...
- 使用 Nginx 提升网站访问速度
使用 Nginx 提升网站访问速度 http://www.ibm.com/developerworks/cn/web/wa-lo-nginx/ Nginx 简介 Nginx ("engine ...
- 使用 Nginx 提升网站访问速度(转)
Nginx 简介 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器. Nginx 是由 Ig ...
随机推荐
- Promise nested then execute order All In One
Promise nested then execute order All In One Promise nested then nested Promise not return new Promi ...
- HTML 5.3
HTML 5.3 W3C Working Draft, 18 October 2018 https://www.w3.org/TR/html53/ refs https://www.w3.org/TR ...
- Flutter: provider 使用小部件的小部件构建的依赖注入系统
文档 dependencies: provider: import 'package:dart_printf/dart_printf.dart'; import 'package:flutter/ma ...
- NGK引入反量子加密系统来应对量子计算攻击
当前,区块链和分布式账本技术已有了长足发展并广泛应用与多种场景中,原因在于其提供透明性,冗余性和问责性的能力.就区块链而言,此类特征是通过公钥加密和哈希函数提供的.但是,随着量子计算机技术的发展和量子 ...
- Matplotlib 图表绘制工具学习笔记
import numpy as np import matplotlib.pyplot as plt import pandas as pd arr1 = np.random.rand(10)#一维数 ...
- 数据库范式(1NF/2NF/3NF)
本文转载自数据库范式(1NF/2NF/3NF) 概述 范式:英文名称是 Normal Form,它是英国人 E.F.Codd(关系数据库的老祖宗)在上个世纪70年代提出关系数据库模型后总结出来的,范式 ...
- 微信小程序:如何实现两个按钮在最右侧并排
要实现的效果: wxml端代码: <view class="prepare_param"> <view clas ...
- DES加密详解
目录 1 根据输入的秘钥得到16个子秘钥 1.1 大致流程 1.2 利用PC-1从K_0中挑出K_1 1.3 利用PC-2从K_1中挑出16个子秘钥 2 利用16个子秘钥对明文进行加密 2.1 大致流 ...
- HDOJ-1160(最长上升子序列变形)
FatMouse's Speed HDOJ-1160 注意输出长度的时候不是输出dp[n] #include<bits/stdc++.h> using namespace std; con ...
- 【Arduino学习笔记01】关于Arduino引脚的一些笔记
参考链接:https://www.yiboard.com/thread-831-1-1.html Arduino Uno R3 - 引脚图 Arduino Uno R3 - 详细参数 Arduino ...