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配置文件示例的更多相关文章

  1. uwsgi配置文件示例

    uwsgi配置文件参考 相关路径请根据自己项目的实际路径配置 在进行Nginx+uwsgi部署Django项目的时候,需要Nginx的配置中包含uwsgi的配置项,具体请查看另一篇:Nginx配置文件 ...

  2. NGINX配置文件优化示例

    Nginx主配置文件 upstream.conf配置文件 # server nginx配置文件最好分开写,不要把所有的逻辑都放在一个文件里面,会看着很麻烦,,之前我的配置文件都放一起了,,导致现在维护 ...

  3. 一、Nginx配置文件详解

    配置文件介绍 主要有两部分:分别是 main:主体部分 http{}:虚拟主机配置部分 配置指令主要以分号结尾:配置语法:directive value1 [value2 ....] 支持使用的变量 ...

  4. nginx配置文件中的location理解

    关于一些对location认识的误区 1. location 的匹配顺序是"先匹配正则,再匹配普通". 矫正: location 的匹配顺序其实是"先匹配普通,再匹配正则 ...

  5. nginx配置文件详解(三)

    nginx配置文件详细解析 nginx安装目录:  /usr/local/nginx 配置文件:  /usr/local/nginx/conf 目录下的 nginx.conf文件 nginx优化方法1 ...

  6. nginx入门示例(二)

    nginx使用域名访问 (Tip)      nginx目录解析 conf/nginx.conf   #主要的配置文件目录 html      #nginx的默认发布目录,部署完后 网站会在这个目录 ...

  7. Nginx配置文件语法教程

    Nginx的配置文件在一开始可能真的不太好理解,就像当初开始使用Apache那样,像JSON但却不是.可以说是Nginx的一种专门语言,仅为Nginx服务的. 市面上基本都是写了一点不写一点的教程,基 ...

  8. nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站

    一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...

  9. Nginx配置文件nginx.conf中文详解(转)

    ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...

随机推荐

  1. pytorch保证每次运行使用的随机数都相同的方法

    其实在代码的开头添加下面几句话即可: # 保证训练时获取的随机数都是一样的 init_seed = torch.manual_seed(init_seed) torch.cuda.manual_see ...

  2. mybatis自动生成后无法获取主键id问题

    使用mybatis的自动生成工具生成的主键id: <selectKey resultType="java.lang.Integer" keyProperty="id ...

  3. LeetCode Top Interview Questions

    LeetCode Top Interview Questions https://leetcode.com/problemset/top-interview-questions/ # No. Titl ...

  4. [LeetCode] 247. Strobogrammatic Number II 对称数II

    A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside ...

  5. Linux安全学习

    安全游戏说明 游戏形式帮助初学者学习和实践网络安全,主要是Linux shell命令的练习. https://overthewire.org/wargames/ 二进制 灰帽黑客进阶秘籍之一--lin ...

  6. Dnsmasq MacOS使用介绍

    Dnsmasq MacOS使用介绍 问题: pc端开发时,需要在/etc/hosts里配置各种本地环境:当开发移动的界面时,除了使用浏览器的"手机模式"查看效果,还可以直接使用手机 ...

  7. Linux配置AndroidSDK&Jenkins远程部署

    最近将公司的项目部署了Jenkins持续集成,遇到了几个麻烦的点,其中之一就是将Android SDK进行配置在远程服务器(总结下来还是自己对Linux命令还不够熟悉),特此记录. 系统: Ubunt ...

  8. 【ARM-Linux开发】Ubuntu下的/usr目录权限,导致不能使用sudo命令的修复

    刚开始运行sudo时,报了下面这个错误 sudo: must be setuid root,于是上网找解决方法,搜索出来的都是这样解决的 ls -l  /usr/bin/sudochown root: ...

  9. async + promise 解决回调地狱

    // 解决异步回调地狱的方案: async + promise async function writeFile() {   // 打开文件   const fd = await new Promis ...

  10. 06 BootStrap前端开发框架(超级好用)

    1.BootStrap概念: 一个前端开发的框架,Bootstrap,来自 Twitter,是目前很受欢迎的前端框架.Bootstrap 是基于 HTML.CSS.JavaScript 的,它简洁灵活 ...