Laravel Homestead-SSL设置 [英] Laravel Homestead - SSL set up

查看:175
本文介绍了Laravel Homestead-SSL设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试开始使用vagrant进行开发-我对使用vagrant进行开发完全陌生-依靠在笔记本电脑上设置的apache/php/mysql.

I'm trying to start to use vagrant for development - I'm completely new to using vagrant for my development - relying on an apache/php/mysql set up on a laptop.

我正在使用laravel进行开发并建立了宅基地并开始运行.

I'm developing using laravel and have set up homestead and am up and running.

我尝试在宅基地(盒子上)上启用SSL,并按照以下说明进行设置:

I've tried to enable SSL on the homestead (box?) and followed these instructions to set up: https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-nginx-for-ubuntu-12-04

我对正在使用的网站的homestead sites_enabled文件进行了更改.

I made the changes to the homestead sites_enabled file for the site i'm working on.

我在服务器内端口80下方添加了端口443,并添加了SSL On等条目

I added port 443 just beneath port 80 within the server,added the entries for SSL On etc

我已经重新启动了nginx服务器,并能够使用https查看我的页面(尽管chrome不喜欢该证书)

I've restarted the nginx server and am able to see my pages using https (although chrome doesn't like the certificate)

如果我随后尝试使用http访问页面,则会出现400错误The plain HTTP request was sent to HTTPS port

If I then try to access pages using http I get a 400 error The plain HTTP request was sent to HTTPS port

那么几个问题: 1.如何更改设置以结合使用HTTP和HTTPS请求? 2.结合HTTP和HTTPS请求为网站提供服务是一种不好的做法-我是否应该将整个网站简单地作为https服务?

so a few questions: 1. how can I alter the set up to use a combination of HTTP and HTTPS requests? 2. is it bad practice to serve a site with a combination of HTTP and HTTPS requests - should I simply serve the whole site as https?

非常困惑于一个全新的主题

Very confused to a completely new subject

谢谢

推荐答案

将端口转发添加到宅基1.x

您需要通过向homestead.rb添加新行来转发SSL端口

Add port forwarding to homestead 1.x

You need to forward the SSL port by adding a new line to homestead.rb

sudo nano /vagrant/scripts/homestead.rb  
# add SSL port forwarding ...
config.vm.network "forwarded_port", guest: 443, host: 44300

创建SSL证书

第一步到第四步

仅从本教程编辑您正在处理的宅基地(用现有站点替换示例)

Edit your homestead site you are working on (replace example with your existing site)

sudo nano /etc/nginx/sites-available/example

复制整个server{…}部分(不仅像您一样复制listen行). 在重复的部分中,将listen 80编辑为listen 443.

Duplicate the whole server{…} section (not only the listen line as you did). In the duplicated section edit listen 80 to listen 443.

在本节末尾之前添加以下行:

Before the end of the section add the following lines:

ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;

exit并执行vagrant reload.

在使用--provision时要小心.您刚才对sites-available/example所做的更改将重置为默认值.

Be careful with --provision. The changes to sites-available/example you just made are reset to default.

如果即使在配置的情况下仍需要永久进行更改,则请查看位于主机的homestead文件夹homstead/scripts/serve.sh中的serve.sh,并将其等同地编辑到步骤5.

If you need to make the changes permanently even in case of provisioning, then have a look at the serve.sh located at your host's homestead folder homstead/scripts/serve.sh and edit it equally to step 5.

在浏览器中使用https://your.domain:44300通过SSL进行访问.如有必要,在浏览器中接受自签名证书.

Use https://your.domain:44300 in your browser to access via SSL. Accept the self signed certificate in your browser if necessary.

这篇关于Laravel Homestead-SSL设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆