IntelliJ IDEA-nginx里配置https访问

上节说了 eclipse-tomcate里配置https访问,这次来说下 IntelliJ IDEA-nginx里配置https访问。

前提:我们公司提供的是CA证书,解压之后是 xxx.pem  xxx.key 两个文件

一、下载 安装windowns下nginx

http://nginx.org/en/download.html

二、cmd进到nginx的安装目录里,启动nginx(start nginx,一闪而过的窗口),浏览器里输入localhost可以看到nginx的欢迎页面,

就说明安装成功了。下面附上nginx的常用命令:

验证配置是否正确: nginx -t
查看Nginx的版本号: nginx -V
启动Nginx: start nginx
快速停止或关闭Nginx: nginx -s stop
正常停止或关闭Nginx: nginx -s quit
配置文件修改重装载命令:nginx -s reload

三、打开\nginx-1.13.12\conf\nginx.conf ,由于我是配置https,http的配置我就不动了。

最下面找到 HTTPS server,把代码给放开,

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

    }

改为

# HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  localhost.clickplus.cn;

        ssl_certificate      D:/DevelopSoftware/apache-tomcat-https/214545238450252.pem;
        ssl_certificate_key  D:/DevelopSoftware/apache-tomcat-https/214545238450252.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;
            proxy_pass http://localhost.clickplus.cn:8082;
        }

    }

改完之后,要关闭nginx服务重新打开,也可以用 nginx -s reload重新装载命令。

四、打开IntelliJ IDEA,配置tomcate服务,如下:


这里我的端口配置的是 8082,很奇怪,我给80或者8081都不行,给8082就好了。。。嘿嘿。这里的端口要和上面的

 proxy_pass 后面的端口要一致。

五、测试一下吧,打开浏览器,输入 https://localhost.clickplus.cn 或者 http://localhost.clickplus.cn:8082

因为tomcate默认,http默认端口是8080,https默认8443,而我们这里只设置了8082,https没有填走的是默认的端口。


配置成功,耶( •̀ ω •́ )y

猜你喜欢

转载自blog.csdn.net/qq_33101675/article/details/80308679
今日推荐