代码编织梦想

nginx配置如下


#user  nobody; #配置用户可在文件上传的时候不报写入异常
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    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;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    gzip  on;
    gzip_comp_level 6;
    gzip_min_length 4k; # 小于4k的文件不会被压缩,大于4k的文件才会去压缩
    gzip_buffers 16 8k; # 处理请求压缩的缓冲区数量和大小,比如8k为单位申请16倍内存空间;使用默认即可,不用修改
    gzip_types text/plain application/x-javascript application/javascript text/javascript text/css application/xml application/x-    httpd-php image/jpeg image/gif image/png application/vnd.ms-fontobject font/x-woff font/ttf;
    gzip_vary on; # 是否在http header中添加Vary: Accept-Encoding,一般情况下建议开启
    server {
        listen       80;
        server_name  ip或域名;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        rewrite ^(.*)$ https://$server_name$request_uri;

        #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;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    server {
        # 监听端口默认是8082
        listen 443 ssl;

        # 服务器ip或域名
        server_name ip或域名;

        # ssl证书(证书存放路径)
        ssl_certificate      /usr/local/nginx/aaa.pem;
        ssl_certificate_key  /usr/local/nginx/aaa.key;

	#if ($scheme = 'http') {
	 #   rewrite ^(.*)$ https://192.168.56.10:8082$request_uri;
	#}

        # 代理动态资源
        location ~ ^/yj {
       	    proxy_buffer_size 64k;
            proxy_buffers   32 32k;
            proxy_busy_buffers_size 128k;
            proxy_pass http://localhost:9208;
            proxy_set_header Host $host:80;
            proxy_max_temp_file_size 0k;
            proxy_connect_timeout 30;
       	    proxy_send_timeout 60;
       	    proxy_read_timeout 60;
	    if ($request_uri ~ '/yj/admin') {
               proxy_pass http://localhost:9012;
	       break;
	    }
	    if ($request_uri ~ '/yj/client') {
               proxy_pass http://localhost:9010;
               break;
            }
    	     
        }

        # 静态资源
        # location ~ \.(ico|js|css|png|jpg|mp4)$ {

          #   proxy_pass http://192.168.140.130:8081;

         #}


    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_19899973/article/details/127969582

nginx从http重定向到https_dbcai的博客-爱代码爱编程_nginx 重定向https

使用nginx把http重定向到https 背景: 1、没有加S的网页容易被嵌入广告 2、没有www的网页,微信支付调用不起来,够坑吧! 解决方案: 1、将http重定向到https 2、将

nginxhttp重定向https_挑灯夜读的博客-爱代码爱编程_nginx 重定向https

Nginx配置同一个域名http与https两种方式都可访问,证书是阿里云上免费申请的   server { listen 80; listen 443 ssl; ssl on; server_name 域名; index index.html index.htm index.php default.html default.htm default.p

如何在Apache和Nginx中将Http重定向到Https-爱代码爱编程

Http is popular protocol used to transfer web page data like HTML, Javascript, Image etc. HTTP is used between our browser like Chrome, Firefox, Edge, Internet Explorer and serv

Nginx如何将HTTP重定向到HTTPS-爱代码爱编程

Nginx,发音为“Engine x”,是一个免费、开源、基于Linux的高性能Web和反向代理服务器,负责管理和处理互联网上最大的网站流量的负载。Nginx是一个强大的重定向工具,可以轻松配置在您的系统上重定向不安全或未加密的HTTP网络流量到加密和安全的HTTPS网络服务器。如果你是一个系统管理员或开发人员,那么你应该经常使用Nginx服务器。 如何

Nginx怎样将HTTP重定向到HTTPS-爱代码爱编程

Nginx是一个强大的重定向工具,可以轻松配置在您的系统上重定向不安全或未加密的HTTP网络流量到加密和安全的HTTPS网络服务器。 Nginx,发音为“Engine x”,是一个免费、开源、基于Linux的高性能Web和反向代理服务器,负责管理和处理互联网上最大的网站流量的负载。Nginx是一个强大的重定向工具,可以轻松配置在您的系统上重定向不安全或未

linux https重定向,在Nginx服务器中将HTTP重定向到HTTPS的方法-爱代码爱编程

在本文中,我们将说明如何在Nginx服务器中将HTTP通信重定向到HTTPS。在Nginx中将HTTP重定向到HTTPS的首选方法是为站点的每个版本配置一个单独的server block,你应该避免使用if指令重定向流量,因为这可能会导致服务器的意外行为。开启HTTPS可参考网站从HTTP升级成HTTPS完全配置教程。 将站点HTTP重定向到HT

nginx中设置http重定向https-爱代码爱编程

首先打开nginx的设定 $ sudo vim /etc/nginx/nginx.conf 添加如下设置,监听80端口并把请求重定向到https. server { listen 80 default; server_name www.example.com; return 301 https://$host$request_uri; } 然后

nginx 配置ssl,并将用户http请求重定向到https-爱代码爱编程

1.下载 Nginx 的证书 里面包含有一个 pem 一个 key,我们把这两个文件先上传到服务器上。 2.配置 nginx.conf 1)第一个server用来监听80端口,并将用户重定向到443。 2)第二个server用来监听443端口,再将刚刚上传至服务器的 pem 和 key 配置上去。 # 监听[www.baidu.com

解决nginx 配置重定向https的问题-爱代码爱编程

网站配置https证书后希望用户访问都能把http请求转为https,于是设置了http 301重定向到https 配置如下: if ($scheme != https) { return 301 https://$host$request_uri; } 然后发现了一个问题,post请求的传参服务端收不到了,因为被重定向了变成get请求了,传

Nginx支持http重定向https(ipv4和ipv6)-爱代码爱编程

http重定向为https server { listen 8088; server_name test1; location / { rewrite ^/(.*) https://[fe80::5870:83ae:efe:7882]:443 permanent; } } server { l

nginx-http重定向到https配置_buddy_88的博客-爱代码爱编程

第一步打开服务器找到nginx目录文件,找到nginx.conf文件进行配置 我们只需要找到http所在的那个服务加入一行代码 return  301 https://www.abc.com$request_uri;  就可以将http协议改成https http{ include mime.types; server{

nginx http 重定向 到https_sir_小三的博客-爱代码爱编程

前言 例如网站 用户之前一直使用http进行访问,现在要更换https,那么为了避免之前的用户还可以使用http进行访问,这个时候就可以利用nginx的重定向,将http 重定向到 htpps,这样用户访问旧的http,会

计算机网络——socket、tcp、http之间的区别与联系_is fang的博客-爱代码爱编程

文章目录 一、 Socket(1)什么是socket(2)为什么需要socket(3)建立socket连接 二、HTTP(基于TCP)(1)HTTP的概念(2)HTTP连接的特点(2.1)连接请求:一次连接(2.

grpc gateway - http restful api & grpc 协议转换_u013433591的博客-爱代码爱编程

gRPC gateway - http restful gRPC gateway 介绍 gRPC-Gateway 是protocalBufffer的编译插件,根据protobuf的服务定义自动生成反向代理服务器,并将Re

http协议中的http报文_前端三脚猫的博客-爱代码爱编程

HTTP中的HTTP报文 1、HTTP报文信息 1.1定义 用于HTTP协议交互的信息叫做HTTP 报文。 HTTP 报文大致可分为报文首部和报文主体两块。两者由最初出现的空行(CR+LF)来划分(通常并不一定要有报