###前提・実現したいこと
ここに質問したいことを詳細に書いてください
(例)PHP(CakePHP)で●●なシステムを作っています。
■■な機能を実装中に以下のエラーメッセージが発生しました。
###発生している問題・エラーメッセージ
エラーメッセージ
###該当のソースコード
server { listen 80; ssl off; server_name example.com www.example.com; root /var/www/example; index index.php; location /example.txt{ } location /example.php{ try_files $uri =404; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_read_timeout 180; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ .(jpg|jpeg)$ { try_files $uri =404; break; } location /{ return 301 https://$server_name$request_uri; } } server { listen 443 ssl http2; server_name example.com www.example.com; root /var/www/example; index index.php; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_dhparam /etc/ssl/certs/dhparam.pem; ssl_stapling on; ssl_stapling_verify on; resolver 8.8.8.8 8.8.4.4; # Set caches, protocols, and accepted ciphers. This config will # merit an A+ SSL Labs score. ssl_session_cache shared:SSL:20m; ssl_session_timeout 10m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5'; error_log /var/log/nginx/example.error.log warn; location / { try_files $uri $uri/ /index.php?$args; } # Allow Lets Encrypt Domain Validation Program location ^~ /.well-known/acme-challenge/ { allow all; } # Block dot file (.htaccess .htpasswd .svn .git .env and so on.) location ~ /. { deny all; } # Block (log file, binary, certificate, shell script, sql dump file) access. location ~* .(log|binary|pem|enc|crt|conf|cnf|sql|sh|key)$ { deny all; } location = /robots.txt { log_not_found off; access_log off; } location = /favicon.ico { log_not_found off; access_log off; } location ~* .(css|js|ico|gif|jpe?g|png|svg|eot|otf|woff|woff2|ttf|ogg)$ { expires max; } location ~ /.well-known { allow all; } location ~ [^/].php(/|$) { try_files $uri =404; fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_read_timeout 180; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
###試したこと
課題に対してアプローチしたことを記載してください
###補足情報(言語/FW/ツール等のバージョンなど)
より詳細な情報
ごんにちは
NginxでJpeg,Jpg,Txt,PhpファイルなどをHTTPでもアクセスができるようにしたいです。
それ以外にはhttpにアクセス時に自動的にhttpsにリダイレクトされるようにしたいです。
ところが、どんなに多くの方法を試してみても、自動的にhttpsにリダイレクトされます。
上記のコードは、私が使ってるサーバブロックです。
何か問題がある場合は教えてくれませんか?
ありがとうございます。
(Ubuntu 16.04 + Nginx 1.10 + Mariadb 10.0 + Php7.0-Fpmを使っています。)
あなたの回答
tips
プレビュー