• nginx配置ssl证书,启动http访问并代理到本地http端口


    小白第一次使用nginx,本地环境Ubuntu 16.04.6

    1、安装Nginx

    sudo apt install nginx

    2、生成证书

    (参考来源:https://segmentfault.com/a/1190000007990972

    1)使用openssl生成密钥privkey.pem:

    openssl genrsa -out privkey.key 1024/2038

    证书信息可以随便填或者留空,只有Common Name要根据你的域名填写。
    2) 使用密钥生成证书server.pem:

    openssl req -new -x509 -key privkey.pem -out server.pem -days 365

    3、修改配置文件

    vim /etc/nginx.conf
    #在 http{}申明内添加以下代码
    server {
            listen 443 ssl http2;
            server_name 172.16.3.64;
    
            root   /var/www/html/;
            index index.php index.html index.htm;
    
            #charset koi8-r;
            access_log /var/log/nginx/access_log;
            error_log   /var/log/nginx/error_log   error;
    
            # SSL/TLS configs
            ssl on;
            ssl_certificate server.pem;
            ssl_certificate_key privkey.key;
    
    
            location / {
                    proxy_pass  http://127.0.0.1:8111;
                    proxy_redirect     off;
                    proxy_set_header   Host             $host;
                    proxy_set_header   X-Real-IP        $remote_addr;
                    proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            }
    }

    4、配置本地项目

    sudo apt install openjdk-8-jdk

    启动springboot项目

      java -jar xxx.jar 

    5、启动nginx查看效果

    service nginx start

    其他命令:sudo systemctl stop|start|restart|reload nginx

    停止/启动/重启/重新加载

    禁用/启用系统服务

    sudo systemctl disable nginx
    sudo systemctl enable nginx

    打开网页,网站启动成功

  • 相关阅读:
    微信小程序HTTPS
    微信商城-1简介
    va_list
    Event log c++ sample.
    EVENT LOGGING
    Analyze Program Runtime Stack
    unknow table alarmtemp error when drop database (mysql)
    This application has request the Runtime to terminate it in an unusual way.
    How to check if Visual Studio 2005 SP1 is installed
    SetUnhandledExceptionFilter
  • 原文地址:https://www.cnblogs.com/passedbylove/p/12049226.html
Copyright © 2020-2023  润新知