1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-24 08:46:24 -07:00

Add HTTP support to the vagrant VM

This commit is contained in:
Eggbertx 2020-10-11 14:59:06 -07:00
parent cba60dc06b
commit cd0ffb4f1f
7 changed files with 34 additions and 8 deletions

1
.gitignore vendored
View file

@ -11,5 +11,6 @@
/templates/override
**/*.bak
*.log
*.swp
__debug_bin
node_modules

3
go.mod
View file

@ -9,10 +9,11 @@ require (
github.com/go-sql-driver/mysql v1.5.0
github.com/lib/pq v1.8.0
github.com/mojocn/base64Captcha v1.3.1
github.com/nranchev/go-libGeoIP v0.0.0-20170629073846-d6d4a9a4c7e8 // indirect
// github.com/nranchev/go-libGeoIP v0.0.0-20170629073846-d6d4a9a4c7e8 // indirect
github.com/tdewolff/minify v2.3.6+incompatible
github.com/tdewolff/parse v2.3.4+incompatible // indirect
github.com/tdewolff/test v1.0.6 // indirect
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
golang.org/x/net v0.0.0-20201009032441-dbdefad45b89
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb
)

4
go.sum
View file

@ -12,6 +12,8 @@ github.com/lib/pq v1.8.0 h1:9xohqzkUwzR4Ga4ivdTcawVS89YSDVxXMa3xJX3cGzg=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mojocn/base64Captcha v1.3.1 h1:2Wbkt8Oc8qjmNJ5GyOfSo4tgVQPsbKMftqASnq8GlT0=
github.com/mojocn/base64Captcha v1.3.1/go.mod h1:wAQCKEc5bDujxKRmbT6/vTnTt5CjStQ8bRfPWUuz/iY=
github.com/nranchev/go-libGeoIP v0.0.0-20170629073846-d6d4a9a4c7e8 h1:IeI4GVfCGrGx4tZROZ/ju+nO9rKpgKJ7o4XmQgAM/2g=
github.com/nranchev/go-libGeoIP v0.0.0-20170629073846-d6d4a9a4c7e8/go.mod h1:CSS25pAr1pT+qxFdpFZIJFHraF4zZfZYeFirlVvLXb4=
github.com/tdewolff/minify v2.3.6+incompatible h1:2hw5/9ZvxhWLvBUnHE06gElGYz+Jv9R4Eys0XUzItYo=
github.com/tdewolff/minify v2.3.6+incompatible/go.mod h1:9Ov578KJUmAWpS6NeZwRZyT56Uf6o3Mcz9CEsg8USYs=
github.com/tdewolff/parse v2.3.4+incompatible h1:x05/cnGwIMf4ceLuDMBOdQ1qGniMoxpP46ghf0Qzh38=
@ -31,6 +33,8 @@ golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+o
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20201009032441-dbdefad45b89 h1:1GKfLldebiSdhTlt3nalwrb7L40Tixr/0IH+kSbRgmk=
golang.org/x/net v0.0.0-20201009032441-dbdefad45b89/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY=
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

View file

@ -3,9 +3,16 @@
# Change as necessary (duh).
server {
listen 80;
listen [::]:80;
server_name localhost;
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl ipv6only=on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
server_name localhost;
client_max_body_size 12M;
location / {

View file

@ -2,9 +2,16 @@
# this should go in /etc/nginx/sites-enabled. Change as necessary.
server {
listen 80;
listen[::]:80;
server_name localhost;
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl ipv6only=on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
server_name localhost;
client_max_body_size 12M;
location / {

1
vagrant/Vagrantfile vendored
View file

@ -17,6 +17,7 @@ Vagrant.configure("2") do |config|
config.ssh.username = "vagrant"
config.vm.box = BOX
config.vm.network "forwarded_port", guest: 80, host: 80
config.vm.network "forwarded_port", guest:443, host:443
config.vm.network :private_network, ip: "172.27.0.3"
config.vm.synced_folder "../", "/vagrant"
config.vm.provider PROVIDER do |provider|

View file

@ -76,6 +76,11 @@ sed -e 's/sendfile on;/sendfile off;/' -i /etc/nginx/nginx.conf
# Make sure our shared directories are mounted before nginx starts
systemctl disable nginx
sed -i 's/WantedBy=multi-user.target/WantedBy=vagrant.mount/' /lib/systemd/system/nginx.service
# generate self-signed certificate since some browsers like Firefox and Chrome automatically do HTTPS requests
# this will likely show a warning in the browser, which you can ignore
openssl req -x509 -nodes -days 7305 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt -subj "/CN=172.27.0.3"
systemctl daemon-reload
systemctl enable nginx
systemctl restart nginx &
@ -90,12 +95,12 @@ sed -i /etc/gochan/gochan.json \
-e 's#"DocumentRoot": "html"#"DocumentRoot": "/srv/gochan"#' \
-e 's#"TemplateDir": "templates"#"TemplateDir": "/usr/local/share/gochan/templates"#' \
-e 's#"LogDir": "log"#"LogDir": "/var/log/gochan"#' \
-e "s/\"DBtype\": .*/\"DBtype\": \"$DBTYPE\",/" \
-e 's/"DBpassword": ""/"DBpassword": "gochan"/' \
-e 's/"Verbosity": 0/"Verbosity": 1/'
if [ "$DBTYPE" = "postgresql" ]; then
sed -i /etc/gochan/gochan.json \
-e 's/"DBtype": ".*"/"DBtype": "postgres"/' \
-e 's/"DBhost": ".*"/"DBhost": "127.0.0.1"/'
fi