we harmoyos 论坛

 找回密码
 立即注册
查看: 339|回复: 0

weharmonyos.com 的 nginx 配置

[复制链接]
  • TA的每日心情
    开心
    2024-1-19 14:48
  • 签到天数: 17 天

    [LV.4]偶尔看看III

    48

    主题

    77

    帖子

    1007

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    积分
    1007
    发表于 2023-12-30 09:40:44 | 显示全部楼层 |阅读模式
    1. ##
    2. # You should look at the following URL's in order to grasp a solid understanding
    3. # of Nginx configuration files in order to fully unleash the power of Nginx.
    4. # https://www.nginx.com/resources/wiki/start/
    5. # https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
    6. # https://wiki.debian.org/Nginx/DirectoryStructure
    7. #
    8. # In most cases, administrators will remove this file from sites-enabled/ and
    9. # leave it as reference inside of sites-available where it will continue to be
    10. # updated by the nginx packaging team.
    11. #
    12. # This file will automatically load configuration files provided by other
    13. # applications, such as Drupal or Wordpress. These applications will be made
    14. # available underneath a path with that package name, such as /drupal8.
    15. #
    16. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
    17. ##

    18. # Default server configuration
    19. #
    20. server {
    21.      #HTTPS的默认访问端口443。
    22.      #如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。
    23.      listen 443 ssl;
    24.      
    25.      #填写证书绑定的域名
    26.      server_name weharmonyos.com www.weharmonyos.com;

    27.      #填写证书文件绝对路径
    28.      ssl_certificate cert/weharmonyos.com.pem;
    29.      #填写证书私钥文件绝对路径
    30.      ssl_certificate_key cert/weharmonyos.com.key;

    31.      ssl_session_cache shared:SSL:1m;
    32.      ssl_session_timeout 5m;
    33.          
    34.      #自定义设置使用的TLS协议的类型以及加密套件(以下为配置示例,请您自行评估是否需要配置)
    35.      #TLS协议版本越高,HTTPS通信的安全性越高,但是相较于低版本TLS协议,高版本TLS协议对浏览器的兼容性较差。
    36.      ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    37.      ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;

    38.      #表示优先使用服务端加密套件。默认开启
    39.      ssl_prefer_server_ciphers on;


    40.     location / {
    41.             root /home/harmony/www/weharmonyos.com;
    42.             index index.html index.htm;
    43.     }
    44.     location ~*\.(js|html|gif|jpg|jpeg|png|css|ico) {
    45.             #proxy_cache  cache_one;
    46.             proxy_cache_key "$host:$server_port$request_uri";
    47.             #proxy_set_header Host $host;
    48.             #proxy_set_header X-Forwarded-For $remote_addr;
    49.             proxy_cache_valid  200 48h;
    50.             add_header X-Cache $upstream_cache_status;
    51.     }
    52. }
    53. server {
    54.     listen 80;
    55.     listen [::]:80;
    56.     #填写证书绑定的域名
    57.     server_name weharmonyos.com www.weharmonyos.com;
    58.     #将所有HTTP请求通过rewrite指令重定向到HTTPS。
    59.     rewrite ^(.*)$ https://$host$1;
    60.     location / {
    61.         index index.html index.htm;
    62.     }
    63. }
    复制代码


    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    手机版|小黑屋|we harmonyos 论坛 ( 粤ICP备 2022126345号 )

    GMT+8, 2024-5-6 23:50 , Processed in 0.048298 second(s), 24 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表