我使用 arch Linux,并尝试为基于 laravel(php 框架)的博客使用安全路由。我尝试让已登录区域的"HTTP"
路由"HTTPS"
与带有虚拟主机服务器块的 nginx 配合使用。使用以下配置,我在同一个配置文件中添加了 http 和 ssl,现在所有路由都被接受为 HTTPS。我如何针对某些路由将它们分开?
server {
listen 80;
server_name remaker.dev;
access_log /var/log/nginx/sirtcantalilar.dev/access.log;
error_log /var/log/nginx/sirtcantalilar.dev/error.log;
#rewrite_log on;
root /home/ytsejam/public_html/remaker/public;
index index.php;
# Added cache headers for images, quick fix for cloudfront.
location ~* \.(png|jpg|jpeg|gif)$ {
expires 30d;
log_not_found off;
}
# Only 3 hours on CSS/JS to allow me to roll out fixes during
# early weeks.
location ~* \.(js|css|ico)$ {
expires 3h;
log_not_found off;
}
# Heres my redirect, try normal URI and then our Laravel urls.
location / {
try_files $uri $uri/ /index.php?$query_string;
# A bunch of perm page redirects from my old
# site structure for SEO purposes. Not interesting.
}
# Look below for this. I decided it was common to Laravel
# sites so put it in an extra template.
# Rewrite for content.
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
location ~* \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
fastcgi_intercept_errors off;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
# Typical vars in here, nothing interesting.
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
server {
listen 443 ssl;
server_name remaker.dev;
access_log /var/log/nginx/sirtcantalilar.dev/access.log;
error_log /var/log/nginx/sirtcantalilar.dev/error.log;
#rewrite_log on;
root /home/ytsejam/public_html/remaker/public;
index index.php;
ssl on;
ssl_certificate /etc/nginx/ssl/remaker.dev/server.crt;
ssl_certificate_key /etc/nginx/ssl/remaker.dev/server.key;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers HIGH:!ADH:!MD5;
# Added cache headers for images, quick fix for cloudfront.
location ~* \.(png|jpg|jpeg|gif)$ {
expires 30d;
log_not_found off;
}
# Only 3 hours on CSS/JS to allow me to roll out fixes during
# early weeks.
location ~* \.(js|css|ico)$ {
expires 3h;
log_not_found off;
}
# Heres my redirect, try normal URI and then our Laravel urls.
location / {
try_files $uri $uri/ /index.php?$query_string;
# A bunch of perm page redirects from my old
# site structure for SEO purposes. Not interesting.
#include /etc/nginx/templates/redirects;
}
# Look below for this. I decided it was common to Laravel
# sites so put it in an extra template.
location ~* \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_index index.php;
fastcgi_intercept_errors off;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
# Typical vars in here, nothing interesting.
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
谢谢帮助。