Skip to content

Commit

Permalink
Changes to make HTTPS work (#195)
Browse files Browse the repository at this point in the history
* Changes to make HTTPS work

* ws_protocol should be different if not use_ssl

oops :)

* Import ws_protocol as well
  • Loading branch information
FrostTheFox authored Jul 26, 2023
1 parent 25b3cb9 commit 4898b25
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ $ cd <root of this repo>
$ ansible-playbook scripts/provision-server.yml -i scripts/hosts --extra-vars "@scripts/variables.yml"
```

If you have set `use_ssl` to `true` in your variables, you will need to install a PEM certificate file and key at `/etc/nginx/od-import.crt` and `/etc/nginx/od-import.key` respectively.


# Known Issues
1. Webpacker compilation fails with no explanation on Linode: this is probably due to lack of memory for the compilation - stop one of the other sites to resolve this.
3 changes: 2 additions & 1 deletion app/javascript/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ActionCableProvider } from 'react-actioncable-provider';
import Navigation from "./navigation/Navigation";
import SiteInfo from "./SiteInfo";
import { sitekey } from "../config";
import { ws_protocol } from "../config";
import AuthorsPage from "./pages/AuthorsPage";
import Container from "react-bootstrap/Container";
import Row from "react-bootstrap/Row";
Expand All @@ -30,7 +31,7 @@ export default class App extends Component {
<div>
<Navigation data={this.props}/>
<SiteInfo config={this.props.config}/>
<ActionCableProvider url={`ws://${window.location.host}/${sitekey}/cable`}>
<ActionCableProvider url={`${ws_protocol}${window.location.host}/${sitekey}/cable`}>
<Container fluid={true}>
<Row>
<Router>
Expand Down
3 changes: 2 additions & 1 deletion app/javascript/config.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const sitekey = 'opendoorstempsite';
export const authors_path = (letter) => `/${sitekey}/authors${ letter ? `?letter=${letter}` :""}`;
export const authors_path = (letter) => `/${sitekey}/authors${ letter ? `?letter=${letter}` :""}`;
export const ws_protocol = 'ws://';
7 changes: 6 additions & 1 deletion scripts/ansible/templates/config.js.j2
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
export const sitekey = "{{ sitekey }}";
export const authors_path = (letter) => `/${sitekey}/authors${ letter ? `?letter=${letter}` :""}`;
export const authors_path = (letter) => `/${sitekey}/authors${ letter ? `?letter=${letter}` :""}`;
{% if use_ssl %}
export const ws_protocol = 'wss://';
{% else %}
export const ws_protocol = 'ws://';
{% endif %}
7 changes: 7 additions & 0 deletions scripts/provision/nginx/sites-available/opendoors-sites.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ map $http_upgrade $connection_upgrade {
}

server {

{% if use_ssl %}
listen 443 ssl http2;
ssl_certificate /etc/nginx/od-import.crt;
ssl_certificate_key /etc/nginx/od-import.key;
{% endif %}

root /var/www;

# Make site accessible from http://localhost/
Expand Down
2 changes: 2 additions & 0 deletions scripts/variables.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ remote_hostname: << hostname for the remote server (added to hosts file) >>
remote_pw: << not used - just convenient for reference >>
remote_pw_hash: << hash of user password >>
local_ssh_path: << path to the public key to add to authorised keys on the server >>

use_ssl: << false / true, note that if true, you will need to install a cert/key for nginx yourself! See the README. >>

0 comments on commit 4898b25

Please sign in to comment.