一分钟实现 nginx 配置实现443端口跳转
程序员文章站
2024-03-14 14:03:22
...
配置用于 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;
}
下一篇: 考研系列之字符串压缩
推荐阅读
-
一分钟实现 nginx 配置实现443端口跳转
-
Nginx配置实例-反向代理实现浏览器请求Nginx跳转到服务器某页面
-
Nginx配置多端口多域名访问的实现
-
使用nginx实现http访问自动跳转到https端口
-
Nginx实现多个站点使用一个端口配置Nginx的虚拟主机 nginx tomcat 虚拟主机 nginx 虚拟主机配置 nginx ssl 虚拟主
-
nginx 代理80端口转443端口的实现
-
使用nginx实现http访问自动跳转到https端口
-
Nginx配置实例-反向代理实现浏览器请求Nginx跳转到服务器某页面
-
Nginx配置实例-反向代理实现浏览器请求Nginx跳转到服务器某页面
-
Nginx配置多端口多域名访问的实现