Nginx配置文件示例
Nginx的配置文件示例:(仅供参考)
强烈建议先将默认的配置文件备份再进行操作!
请根据自己项目的实际路径来配置相关路径!
uwsgi配置文件请参考:uwsgi配置文件示例
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
# user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
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;
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;
server_name www.******.com;
charset utf-8;
rewrite ^(.*)$ https://www.******.com permanent;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
# 如果用到了ssl,就把下面这一段注释掉。否则的话需要解开注释,把后面监听443端口的都注释掉
# location /api{
# include uwsgi_params;
# uwsgi_pass 127.0.0.1:8001; # 转发到内部8001端口来处理,必须和uwsgi中的设置一致
# client_max_body_size 35m;
# }
#
# location / {
# root /home/www/blog_front;
# index index.html;
# }
#
# location /static {
# alias /home/blog/Blog/statics;
#
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
}
# 如果没有ssl证书可以不填写这个,或者全部注释掉
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
# server_name ******.com;
# rewrite ^(.*)$ https://www.******.com permanent;
# root /usr/share/nginx/html;
ssl on;
ssl_certificate "/etc/pki/nginx/server.crt"; # 这里根据自己的ssl证书的路径填写
ssl_certificate_key "/etc/pki/nginx/private/server.key"; # 这里根据自己的ssl证书的路径填写
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
# 这里的/api表示后端请求的地址为https://域名:端口/api/参数
location /api{
include uwsgi_params;
uwsgi_pass 127.0.0.1:8001; # 转发到内部8001端口来处理,必须和uwsgi中的设置一致
client_max_body_size 35m;
}
location / {
root /home/www/blog_front;
index index.html;
}
location /static {
alias /home/blog/Blog/statics;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
转载请注明出处!
Nginx配置文件示例的更多相关文章
- uwsgi配置文件示例
uwsgi配置文件参考 相关路径请根据自己项目的实际路径配置 在进行Nginx+uwsgi部署Django项目的时候,需要Nginx的配置中包含uwsgi的配置项,具体请查看另一篇:Nginx配置文件 ...
- NGINX配置文件优化示例
Nginx主配置文件 upstream.conf配置文件 # server nginx配置文件最好分开写,不要把所有的逻辑都放在一个文件里面,会看着很麻烦,,之前我的配置文件都放一起了,,导致现在维护 ...
- 一、Nginx配置文件详解
配置文件介绍 主要有两部分:分别是 main:主体部分 http{}:虚拟主机配置部分 配置指令主要以分号结尾:配置语法:directive value1 [value2 ....] 支持使用的变量 ...
- nginx配置文件中的location理解
关于一些对location认识的误区 1. location 的匹配顺序是"先匹配正则,再匹配普通". 矫正: location 的匹配顺序其实是"先匹配普通,再匹配正则 ...
- nginx配置文件详解(三)
nginx配置文件详细解析 nginx安装目录: /usr/local/nginx 配置文件: /usr/local/nginx/conf 目录下的 nginx.conf文件 nginx优化方法1 ...
- nginx入门示例(二)
nginx使用域名访问 (Tip) nginx目录解析 conf/nginx.conf #主要的配置文件目录 html #nginx的默认发布目录,部署完后 网站会在这个目录 ...
- Nginx配置文件语法教程
Nginx的配置文件在一开始可能真的不太好理解,就像当初开始使用Apache那样,像JSON但却不是.可以说是Nginx的一种专门语言,仅为Nginx服务的. 市面上基本都是写了一点不写一点的教程,基 ...
- nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站
一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...
- Nginx配置文件nginx.conf中文详解(转)
######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...
随机推荐
- [译]在你的GitHub主页固定仓库
原文来源:https://github.blog/2016-06-16-pin-repositories-to-your-github-profile/ 您现在可以在GitHub主页上展示最能代表您工 ...
- Spring MVC -- 转换器和格式化
在Spring MVC -- 数据绑定和表单标签库中我们已经见证了数据绑定的威力,并学习了如何使用表单标签库中的标签.但是,Spring的数据绑定并非没有任何限制.有案例表明,Spring在如何正确绑 ...
- TensorFlow.js-机器学习
一.参考学习 https://blog.csdn.net/Quincylk/article/details/85340004 http://www.tensorfly.cn/tfdoc/get_sta ...
- [LeetCode] 210. Course Schedule II 课程安排II
There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prer ...
- [LeetCode] 387. First Unique Character in a String 字符串的第一个唯一字符
Given a string, find the first non-repeating character in it and return it's index. If it doesn't ex ...
- sshpass命令使用
1.直接远程连接某主机 sshpass -p {密码} ssh {用户名}@{主机IP} 2.远程连接指定ssh的端口 sshpass -p {密码} ssh -p ${端口} {用户名}@{主机IP ...
- mysql查询列为空
SELECT * FROM `表名` WHERE ISNULL(列名)
- jquery swiper自定义pagination的方法
jquery swiper自定义pagination的方法<pre><script>var swiper = new Swiper('.swiper-container', { ...
- 罗辑思维首席架构师:Go微服务改造实践
转自:http://www.infoq.com/cn/news/2018/05/luojisiwei 方圆 曾先后在 Cisco,新浪微博从事基础架构研发工作.十多年一直专注于后端技术的研发,在消息通 ...
- 【计算机网络基础】URI、URN和URL的区别
先引用一张关系图 灰色部分为URI URI强调的是给资源标记命名,URL强调的是给资源定位. URI是Uniform Resource Identifier,表示是一个资源: URL是Uniform ...