nginx基本用法和HTTPS配置

nginx作用讲解:1.反向代理:需要多个程序共享80端口的时候就需要用到反向代理,nginx是反向代理的一种实现方式。2.静态资源管理:一般使用nginx做反向代理的同时,应该把静态资源交由nginx管理。3.负载均衡:略。

nginx原理:nginx实质是通过配置文件创建监听80端口的服务器,然后通过该服务器重定向请求到指定端口。

nginx实现HTTPS访问:原理同上文,使用配置文件创建HTTPS服务器,然后通过该服务器重定向请求到指定端口。

为什么要用nginx管理静态资源?1.减少了重定向耗时2.nginx提供了高性能的静态资源管理

在Ubuntu上安装nginx:参考官网:https://www.nginx.com/resources/wiki/start/topics/tutorials/install/

启动nginx:/usr/sbin/nginx重启nginx:/usr/sbin/nginx -s reload退出nginx:/usr/sbin/nginx -s quit

新增一个nginx配置,可以仿照/etc/nginx/conf.d/veily.conf,增加一个server。示例:server {        listen       80;        server_name  xcx.veilytech.com;        rewrite  ^/(.*)$ https://xcx.xxxx.com:443/$1 permanent;}

server {        listen 443 ssl;        ssl_certificate /etc/letsencrypt/live/xcx.xxxx.com/fullchain.pem;        ssl_certificate_key /etc/letsencrypt/live/xcx.xxxx.com/privkey.pem;        keepalive_timeout   70;        server_name xcx.xxxx.com;        #禁止在header中出现服务器版本,防止黑客利用版本漏洞攻击        server_tokens off;        # ......        fastcgi_param   HTTPS               on;        fastcgi_param   HTTP_SCHEME         https;        location / {              proxy_pass http://127.0.0.1:8093/;       }}

原文地址:https://www.cnblogs.com/jarvisjin/p/8400420.html

时间: 2024-08-30 12:39:16

nginx基本用法和HTTPS配置的相关文章

Nginx作为WEB服务相关配置(性能优化,网络连接,访问控制,虚拟主机,https等等)

编译安装nginx yum -y install pcre-devel groupadd -r nginx useradd -g nginx -r nginx tar xf nginx-1.6.2.tar.gz cd nginx-1.6.2 ./configure --prefix=/usr/local/nginx --conf-path=/etc/nginx/nginx.conf--user=nginx --group=nginx --error-log-path=/var/log/nginx

Nginx 学习笔记(一)个人网站的Https配置

一.系统环境 1.系统:Ubuntu 16.04.2 LTS 2.WEB服务器:Openresty11.2.5 二.开始配置 1.获取certbot客户端 wget https://dl.eff.org/certbot-auto chmod a+x certbot-auto 2.停止Nginx服务 sudo systemctl stop nginx.service 3.生成证书 ./certbot-auto certonly --standalone --email `你的邮箱地址` -d `你

nginx配置及HTTPS配置示例

一.nginx简单配置示例 user www www; worker_processes 10; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; #最大文件描述符 worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } ht

在阿里云域名https配置(nginx为例)

如题: 在阿里云上注册了域名之后在阿里云域名控制台配置https: 1.在域名控制台选择要配置的域名,并在操作栏点击"解析" 2.在域名解析点击更多下的SSL进入到证书列表页,这里有收费的也有免费的,公司的建议用收费的个人网站免费够我们用了,不过免费的话是免费一年的,第二年到期前再下载一个免费的替换就可以了. 3.在证书列表也配置你要设置https域名,并勾选系统自动添加TXT解析记录 4.申请成功后在解析设置新增解析记录TXT,然后下载证书,会得到两个文件分别是.pem和.key结尾

nginx普通配置/负载均衡配置/ssl/https配置

1.nginx普通配置 server { listen 80; server_name jqlin.lynch.com; access_log /var/log/nginx/main.log main; error_log /var/log/nginx/pay_local.error; #log_format access '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent $re

配置nginx防盗链和HTTPS

一.配置nginx图片防盗链步骤1:配置盗链网站 1)启动nginx容器,设置端口映射,并进入容器 docker run -d --privileged -p 80:80 nginx /usr/sbin/init 2)在nginx容器中准备两个网站,配置文件截图 server {listen 80;server_name site1.test.com;root /var/www/html/site1;index index.html;}server {listen 80;server_name

spring boot 1.x nginx前置https配置及注意点

首先参考nginx配置https并强制http自动跳转到https配置nginx的https证书. 然后在application.properties中加上属性如下: server.tomcat.remote_ip_header=x-forwarded-for server.tomcat.protocol_header=x-forwarded-proto server.tomcat.port-header=X-Forwarded-Port server.use-forward-headers=t

haproxy代理https配置方法

记得在之前的一篇文章中介绍了nginx反向代理https的方法,今天这里介绍下haproxy代理https的方法: haproxy代理https有两种方式:1)haproxy服务器本身提供ssl证书,后面的web服务器走正常的http 2)haproxy服务器本身只提供代理,后面的web服务器走https(配置ssl证书) 第一种方式:haproxy服务器本身提供ssl证书 注意:需要编译haproxy的时候支持ssl编译参数: #make TARGET=linux26 USE_OPENSSL=

Windows下Nginx Virtual Host多站点配置详解

Windows下Nginx Virtual Host多站点配置详解 此教程适用于Windows系统已经配置好Nginx+Php+Mysql环境的同学. 如果您还未搭建WNMP环境,请查看 windows7配置Nginx+php+mysql教程. 先说明一下配置多站点的目的:在生产环境中,如果将系统所有代码文件都放在公开目录中,则很容易被查看到系统源码,这样是很不安全的,所以需要只公开index.php的入口文件目录.而同一个服务器中,可能运行多个系统,这样就必须公开多个入口文件目录,以便用不同的