首页 > 编程知识 正文

nginx配置端口转发,非443端口配置https

时间:2023-05-04 06:59:38 阅读:216691 作者:4921

配置用于 nginx 配置,实现443端口的跳转 server { listen 80; server_name abc.com; return 301 https://$host$request_uri; #可用301跳转(选其一) rewrite ^(.*)$ https://abc.com$1 permanent; #也可用地址重写规则(选其一)}server { listen 443 ssl; server_name abc.com; ssl_certificate /etc/nginx/ssl/abc.crt; ssl_certificate_key /etc/nginx/ssl/abc.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:-LOW:!aNULL:!eNULL; ssl_prefer_server_ciphers on; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-Wit,content-typeh; add_header Access-Control-Allow-Methods GET,POST,OPTIONS; location / { root /home/abc; } access_log off;} 配置可用于 php 环境,同时实现443端口的跳转 server { listen 80; server_name abc.com; return 301 https://$host$request_uri; #可用301跳转(选其一) rewrite ^(.*)$ https://abc.com$1 permanent; #也可用地址重写规则(选其一)}server { listen 443 ssl; server_name abc.com; ssl_certificate /etc/nginx/ssl/abc.crt; ssl_certificate_key /etc/nginx/ssl/abc.key; root /usr/share/nginx/abc.com/; index index.php index.html index.htm;location ~ .php($|/) { fastcgi_pass 127.0.0.1:9000; fastcgi_read_timeout 300; fastcgi_index index.php; fastcgi_split_path_info ^(.+.php)(.*)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-Wit,content-typeh; add_header Access-Control-Allow-Methods GET,POST,OPTIONS; } location / { try_files $uri $uri/ /index.php$is_args$query_string; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } access_log off;}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。