Nginx监听多端口以及Https多端口,就是两端server
https则需要配置证书
server {#listen8181;#server_name192.168.0.1#charset koi8-r;#access_loglogs/host.access.logmain;#rewrite ^(.*)$ https://$host$1 permanent;}# HTTPS server#server {listen8080 ssl;server_name192.168.0.1 ;ssl_certificate/usr/local/nginx/cert/xxx.crt;ssl_certificate_key/usr/local/nginx/cert/xxx.key;ssl_session_cacheshared:SSL:1m;ssl_session_timeout30m;#ssl_ciphersHIGH:!aNULL:!MD5;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_cipherson;location / {root/home/release/dist;indexindex.html index.htm;}location ^~ /api/ {proxy_pass http://127.0.0.1:9999;proxy_cookie_path / /;proxy_pass_header Set-Cookie;proxy_set_header Host zans;}proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}# HTTPS server#server {listen443 ssl;server_namexxx.com ;ssl_certificate/usr/local/nginx/cert/xxx.crt;ssl_certificate_key/usr/local/nginx/cert/xxx.key;ssl_session_cacheshared:SSL:1m;ssl_session_timeout30m;#ssl_ciphersHIGH:!aNULL:!MD5;ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;ssl_protocols TLSv1 TLSv1.1 TLSv1.2;ssl_prefer_server_cipherson;location / {root/home/release/app;indexindex.html index.htm;}location ^~ /api {proxy_pass http://127.0.0.1:6666;proxy_cookie_path / /;proxy_pass_header Set-Cookie;proxy_set_header Host zans;}proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}
错误处理1 , Nginx: error while loading shared libraries: libpcre.so.1
则说明未安装pcre或安装了未设置软链,安装或者设置器软链即可
ln -s /usr/local/lib/libpcre.so.1 /lib64/
2 , 实现负载均衡之后 , 页面无法跳转
原因: nginx 默认的端口是80,更改监听的端口之后 , 也需要更改一下 。
也会出现这种错误:net::ERR_NAME_NOT_RESOLVED
解决办法:在location 下添加proxy_set_header Host$host:port
这个配置,port 和listen 的端口保持一致, 不然是无法跳转的 。
3 , 使用文件服务器的一些问题
- nginx需要设置传输的大小;
- 【手记系列之三 ----- 关于使用Nginx的一些使用方法和经验】访问若出现了403权限问题,一般情况下是上传的图片用root创建的,但nginx访问使用nginx用户访问的,所以在linux系统出现了问题 。解决办法一:nginx使用root用户启动,在nginx的配置改成 use root;解决办法二:全局设置文件夹的权限 , 并且使nginx拥有读取的权限;
- nginx限速问题 , 如果宽带不高,可以对大图片文件进行限速 。
推荐阅读
- 苹果iPhone13系列价格预测_iPhone13系列上市最新价格
- 34 《吐血整理》高级系列教程-吃透Fiddler抓包教程-Fiddler如何抓取微信小程序的包-上篇
- 3050ti能玩3a吗_3050ti带的动3a游戏吗
- 【Spring系列】- 手写模拟Spring框架
- 中 学习ASP.NET Core Blazor编程系列十——路由
- 苹果13mini屏幕多大尺寸_苹果13mini屏幕尺寸
- Redis系列10:HyperLogLog实现海量数据基数统计
- 1 Dive into TensorFlow系列-静态图运行原理
- 【k8s连载系列】2. k8s整体架构
- 深唇口红排行榜10强 显色度超好,深唇和黄皮必入系列