How to share a vagrant machine with https

安稳与你 提交于 2020-04-15 11:33:54

问题


I have a working vagrant VM I want to Share. In my Vagrantfile I have:

config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.1.15"
config.vm.network "forwarded_port", guest: 443, host: 443

in the virtual host I have

<VirtualHost *:443>
...
ServerAlias *.vagrantshare.com
....
</Virtualhost>

not sure about the first line but it was there already

I share the machine with

vagrant share --https 443

this is the output:

==> default: Detecting network information for machine...
default: Local machine address: 127.0.0.1
default:  
default: Note: With the local address (127.0.0.1), Vagrant Share can only
default: share any ports you have forwarded. Assign an IP or address to your
default: machine to expose all TCP ports. Consult the documentation
default: for your provider ('virtualbox') for more information.
default:  
default: Local HTTP port: 8080
default: Local HTTPS port: 443
default: Port: 2222
default: Port: 443
default: Port: 8080
==> default: Checking authentication and authorization...
==> default: Creating Vagrant Share session...
default: Share will be at: towering-badger-9312
==> default: Your Vagrant Share is running! Name: towering-badger-9312
==> default: URL: http://towering-badger-9312.vagrantshare.com
==> default:  
==> default: You're sharing your Vagrant machine in "restricted" mode. This
==> default: means that only the ports listed above will be accessible by
==> default: other users (either via the web URL or using `vagrant connect`).

I can see it in vagrant cloud but I got an error while trying to access it via https:

towering-badger-9312.vagrantshare.com is currently unable to handle this request.
HTTP ERROR 500

not any other useful message in the console, any idea how to debug this?

thanks


回答1:


Replace this line

config.vm.network "forwarded_port", guest: 443, host: 443

with i.e.

config.vm.network "forwarded_port", guest: 443, host: 8443

first, because forwarded_port is for accessing from your host and second, you should not be able to bind to port 443 on host.

Also

vagrant share --https 443

is redundant (docs):

HTTPS (SSL)

Vagrant Share can also expose an SSL port that can be accessed over SSL. For example, instead of accessing http://foo.vagrantshare.com, it could be accessed at https://foo.vagrantshare.com.

vagrant share by default looks for any SSL traffic on port 443 in your development environment. If it cannot find any, then SSL is disabled by default.

so

vagrant share

should suffice (assuming there's no other issue).



来源:https://stackoverflow.com/questions/41959644/how-to-share-a-vagrant-machine-with-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!