forked from RocketMap/RocketMap
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
nginx Reverse Proxy
        tkSimon edited this page Jul 30, 2016 
        ·
        3 revisions
      
    If you do not want to expose pokemongo-map to the web directly or you want to place it under a prefix, follow this guide:
Assuming the following:
- You are running pokemongo-map on the default port 5000
- You've already made your machine available externally (such as with ngrok)
- Install nginx (I'm not walking you through that, google will assist) - http://nginx.org/en/linux_packages.html
- In /etc/nginx/nginx.confadd the following before the last}.
 (Note: this is not required if the last line of yournginx.conffile has this:include /etc/nginx/conf.d/*.conf;
 include conf.d/pokemongo-map.conf;
- Create a file /etc/nginx/conf.d/pokemongo-map.conf and place the following in it:
- create pokemongo-map.conf nano /etc/nginx/conf.d/pokemongo-map.conf
- If you want to access your maps at www.YourDomain.com/go/: (note the trailing slash!)
      location /go/ {
         proxy_pass http://127.0.0.1:5000/;
      }
- If you want to access your maps at www.YourDomain.com:
      location / {
         proxy_pass http://127.0.0.1:5000/;
      }
- Test your nginx config: service nginx configtest
- Reload/Restart your nginx service: service nginx restart
- You can now access it by http://yourip/goorhttp://yourip
###Add a free SSL Certificate to your site:
- https://certbot.eff.org/#debianjessie-nginx
- For webroot configuration, simplest for this use, do the following:
- Edit your /etc/nginx/conf.d/pokemongo-map.conf
- Add the following location block:
 location /.well-known/acme-challenge {
   default_type "text/plain";
   root /var/www/certbot;
 }
- Create the root folder above mkdir /var/www/certbot
- Set your permissions for the folder so that nginx can access the folder
- Either chown -R www-data:www-data /var/www/certbot
- or chown -R nginx:nginx /var/www/certbot
- you can figure out which one but looking at nginx.conf(the first line says eitheruser nginxoruser www-data)
- Run certbot certonly -w /var/www/certbot -d yourdomain.something.com
- Certificates last for 3 Months and can be renewed by running certbot renew
###Example Config with SSL Cert
server {
    listen       80;
    server_name  PokeMaps.yourdomain.com;
   location /.well-known/acme-challenge {
     default_type "text/plain";
     root /var/www/certbot;
   }
  #Forces all other requests to HTTPS
  location / {
     return      301 https://$host$request_uri;
  }
}
server {
  listen 443 ssl http2;
  server_name PokeMaps.yourdomain.com;
  ssl_certificate /etc/letsencrypt/live/xxxxxxxxxxxxxxxxxxxxxx/fullchain.pem; #add this after you run CertBot
  ssl_certificate_key /etc/letsencrypt/live/xxxxxxxxxxxxxxxxxxxxxx/privkey.pem;  #add this after you run CertBot
  location /go/ {
   proxy_pass http://127.0.0.1:5000/;
   proxy_redirect off;
  }