How To Migrate a Parse App to Parse Server on Ubuntu 14.04
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

546 lines
27 KiB

6 years ago
6 years ago
6 years ago
  1. <!DOCTYPE html>
  2. <html lang=en>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>How To Migrate a Parse App to Parse Server on Ubuntu 14.04</title>
  6. <link rel=stylesheet href="fake-it.css" />
  7. </head>
  8. <body>
  9. <h1>How To Migrate a Parse App to Parse Server on Ubuntu 14.04 (ROUGH DRAFT - INCOMPLETE)</h1>
  10. <h3>Introduction</h3>
  11. <p>Parse is a Mobile Backend as a Service platform, owned by Facebook since 2013. In January of 2016, Parse announced that its hosted services would shut down completely on January 28, 2017. In order to help its users transition away from the service, Parse has released an open source version of its backend, called <strong>Parse Server</strong>, which can be deployed to environments running Node.js and MongoDB.</p>
  12. <p>This guide focuses on migrating a pre-existing Parse application to a standalone instance of Parse Server, with TLS/SSL encryption for all connections using a certificate provided by Let&rsquo;s Encrypt.</p>
  13. <p>&lt;$>[warning]
  14. <strong>Warning:</strong> It is strongly recommended that this procedure first be tested with a development or test version of the app before attempting it with a user-facing production app.
  15. &lt;$></p>
  16. <h2>Prerequisites</h2>
  17. <p>This guide builds on <a href="">How To Run Parse Server on Ubuntu 14.04</a>. It requires the following:</p>
  18. <ul>
  19. <li>An Ubuntu 14.04 server, configured with a non-root <code>sudo</code> user</li>
  20. <li>A recent Node.js release</li>
  21. <li>MongoDB 3.0.x</li>
  22. <li>A domain name pointing at the server</li>
  23. <li>A Parse App to be migrated</li>
  24. </ul>
  25. <p>The target server should have enough storage to handle all of your app&rsquo;s data. Since Parse compresses data on their end, they officially recommend that you provision at least 10 times as much storage space as used by your hosted app.</p>
  26. <h2>Step 1 – Install Let&rsquo;s Encrypt and Retrieve a Certificate</h2>
  27. <h3>Install Let&rsquo;s Encrypt and Dependencies</h3>
  28. <p>Let&rsquo;s Encrypt is a Certificate Authority that provides an easy way to obtain free TLS/SSL certificates. Because a certificate is necessary to secure both the migration of data to MongoDB and your Parse Server API endpoint, we&rsquo;ll begin by retrieving one with the <code>letsencrypt</code> client.</p>
  29. <p>You must own or control the registered domain name that you wish to use the certificate with. If you do not already have a registered domain name, you may register one with one of the many domain name registrars out there (e.g. Namecheap, GoDaddy, etc.).</p>
  30. <p>If you haven&rsquo;t already, be sure to create an <strong>A Record</strong> that points your domain to the public IP address of your server. This is required because of how Let&rsquo;s Encrypt validates that you own the domain it is issuing a certificate for. For example, if you want to obtain a certificate for <code></code>, that domain must resolve to your server for the validation process to work.</p>
  31. <p>For more detail on this process, see <a href="">How To Set Up a Host Name with DigitalOcean</a> and <a href="">How To Point to DigitalOcean Nameservers from Common Domain Registrars</a>.</p>
  32. <p>Begin by making sure that the <code>git</code> and <code>bc</code> packages are installed:</p>
  33. <pre><code class="command">sudo apt-get -y install git bc
  34. </code></pre>
  35. <p>Next, clone the <code>letsencrypt</code> repository from GitHub to <code>/opt/letsencrypt</code>. The <code>/opt/</code> directory is a standard location for software that&rsquo;s not installed from official packages:</p>
  36. <pre><code class="command">sudo git clone /opt/letsencrypt
  37. </code></pre>
  38. <p>Change to the <code>letsencrypt</code> directory:</p>
  39. <pre><code class="command">cd /opt/letsencrypt
  40. </code></pre>
  41. <h3>Retrieve Initial Certificate</h3>
  42. <p>Run <code>letsencrypt</code> with the Standalone plugin:</p>
  43. <pre><code class="command">./letsencrypt-auto certonly --standalone
  44. </code></pre>
  45. <p>You&rsquo;ll be prompted to answer several questions, including your email address, agreement to a Terms of Service, and the domain name(s) for the certificate. Once finished, you&rsquo;ll receive notes much like the following:</p>
  46. <pre><code>IMPORTANT NOTES:
  47. - Congratulations! Your certificate and chain have been saved at
  48. /etc/letsencrypt/live/<span style="color: red;">your_domain_name</span>/fullchain.pem. Your cert will expire
  49. on <span style="color: red;">2016-05-16</span>. To obtain a new version of the certificate in the
  50. future, simply run Let's Encrypt again.
  51. - If you like Let's Encrypt, please consider supporting our work by:
  52. Donating to ISRG / Let's Encrypt:
  53. Donating to EFF:
  54. </code></pre>
  55. <p>Note the path and expiration date of your certificate, highlighted in the example output. Your certificate files should now be available in <code>/etc/letsencrypt/<span style="color: red;">your_domain_name</span>/</code>.</p>
  56. <h3>Set Up Let&rsquo;s Encrypt Auto Renewal</h3>
  57. <p>&lt;$>[warning]
  58. <strong>Warning:</strong> You can safely complete this guide without worrying about certificate renewal, but you will need to address it for any long-lived production environment.
  59. &lt;$></p>
  60. <p>You may have noticed that your Let&rsquo;s Encrypt certificate is due to expire in 90 days. This is a deliberate feature of the Let&rsquo;s Encrypt approach, intended to minimize the amount of time that a compromised certificate can exist in the wild if something goes wrong.</p>
  61. <p>Let&rsquo;s Encrypt is still in beta. Better auto-renewal features are planned, but in the meanwhile you will either have to repeat the certificate retrieval process by hand, or use a scheduled script to handle it for you. The details of automating this process are covered in <a href="">How To Secure Nginx with Let&rsquo;s Encrypt on Ubuntu 14.04</a>, particularly the section on <a href="">setting up auto renewal</a>.</p>
  62. <h2>Step 2 – Configure MongoDB for Migration</h2>
  63. <p>Parse provides a migration tool for existing applications. In order to make use of it, we need to open MongoDB to external connections and secure it with a copy of the TLS/SSL certificate from Let&rsquo;s Encrypt. Start by combining <code>fullchain1.pem</code> and <code>privkey1.pem</code> into a new file in <code>/etc/ssl</code>:</p>
  64. <pre><code class="command">sudo cat /etc/letsencrypt/archive/<span style="color: red;">domain_name</span>/{fullchain1.pem,privkey1.pem} | sudo tee /etc/ssl/mongo.pem
  65. </code></pre>
  66. <p>&lt;$>[note]
  67. You will have to repeat the above command after renewing your Let&rsquo;s Encrypt certificate. If you configure auto-renewal of the Let&rsquo;s Encrypt certificate, remember to include this operation.
  68. &lt;$></p>
  69. <p>Make sure <code>mongo.pem</code> is owned by the <strong>mongodb</strong> user, and readable only by its owner:</p>
  70. <pre><code class="command">sudo chown mongodb:mongodb /etc/ssl/mongo.pem
  71. sudo chmod 600 /etc/ssl/mongo.pem
  72. </code></pre>
  73. <p>Now, open <code>/etc/mongod.conf</code> in <code>nano</code> (or your text editor of choice):</p>
  74. <pre><code class="command">sudo nano /etc/mongod.conf
  75. </code></pre>
  76. <p>Here, we&rsquo;ll make several important changes.</p>
  77. <p>First, look for the <code>bindIp</code> line in the <code>net:</code> section, and tell MongoDB to listen on all addresses by changing <code></code> to <code></code>. Below this, add SSL configuration to the same section:</p>
  78. <pre><code><strong>/etc/mongod.conf</strong><br>
  79. # network interfaces
  80. net:
  81. port: 27017
  82. bindIp: <span style="color: red;"></span>
  83. <span style="color: red;">ssl:</span>
  84. <span style="color: red;">mode: requireSSL</span>
  85. <span style="color: red;">PEMKeyFile: /etc/ssl/mongo.pem</span>
  86. </code></pre>
  87. <p>Next, under <code># security</code>, enable client authorization:</p>
  88. <pre><code><strong>/etc/mongod.conf</strong><br>
  89. # security
  90. security:
  91. authorization: enabled
  92. </code></pre>
  93. <p>Finally, the migration tool requires us to set the <code>failIndexKeyTooLong</code> parameter to <code>false</code>:</p>
  94. <pre><code><strong>/etc/mongod.conf</strong><br>
  95. setParameter:
  96. failIndexKeyTooLong: false
  97. </code></pre>
  98. <p>&lt;$>[note]
  99. <strong>Note:</strong> Whitespace is significant in MongoDB configuration files, which are based on <a href="">YAML</a>. When copying configuration values, make sure that you preserve indentation.
  100. &lt;$></p>
  101. <p>Exit and save the file.</p>
  102. <p>Before restarting the <code>mongod</code> service, we need to add a user with the <code>admin</code> role. Connect to the running MongoDB instance:</p>
  103. <pre><code class="command">mongo --port 27017
  104. </code></pre>
  105. <p>Create an admin user and exit. Be sure to replace &lt;^>sammy&lt;^> with your desired username and &lt;^>password&lt;^> with a strong password.</p>
  106. <pre><code>use admin
  107. db.createUser({
  108. user: "<span style="color: red;">sammy</span>",
  109. pwd: "<span style="color: red;">password</span>",
  110. roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  111. })
  112. exit
  113. </code></pre>
  114. <p>Restart the <code>mongod</code> service:</p>
  115. <pre><code class="command">sudo service mongod restart
  116. </code></pre>
  117. <h2>Step 2 – Migrate Application Data from Parse</h2>
  118. <p>Now that you have a remotely-accessible MongoDB instance, you can use the Parse migration tool to transfer your app&rsquo;s data to your server.</p>
  119. <h3>Configure MongoDB Credentials for Migration Tool</h3>
  120. <p>We&rsquo;ll begin by connecting locally with our new admin user:</p>
  121. <pre><code class="command">mongo --port 27017 --ssl --sslAllowInvalidCertificates --authenticationDatabase admin --username <span style="color: red;">sammy</span> --password
  122. </code></pre>
  123. <p>You should be prompted to enter the password you set earlier.</p>
  124. <p>Once connected, choose a name for the database to store your app&rsquo;s data. For example, if you&rsquo;re migrating an app called Todo, you might use <code>todo</code>. You&rsquo;ll also need to pick another strong password for a user called <strong>parse</strong>.</p>
  125. <p>From the <code>mongo</code> shell, give this user access to <code><span style="color: red;">database_name</span></code>:</p>
  126. <pre><code class="custom_prefix(>)">use <span style="color: red;">database_name</span>
  127. db.createUser({ user: "parse", pwd: "<span style="color: red;">password</span>", roles: [ "readWrite", "dbAdmin" ] })
  128. </code></pre>
  129. <h3>Initiate Data Migration Process</h3>
  130. <p>In a browser window, log in to Parse, and open the settings for your app. Under <strong>General</strong>, locate the <strong>Migrate</strong> button and click it:</p>
  131. <p><img src="" alt="Parse App Settings: General: Migrate" /></p>
  132. <p>You will be prompted for a MongoDB connection string. Use the following format:</p>
  133. <pre><code>mongodb://parse:<span style="color: red;">password</span>@<span style="color: red;">your_domain_name</span>:27017/<span style="color: red;">database_name</span>?ssl=true
  134. </code></pre>
  135. <p>For example, if you are using the domain <code></code>, with the user <code>parse</code>, the password <code>foo</code>, and a database called <code>todo</code>, your connection string would look like this:</p>
  136. <pre><code>mongodb://
  137. </code></pre>
  138. <p>Don&rsquo;t forget <code>?ssl=true</code> at the end, or the connection will fail. Enter the connection string into the dialog like so:</p>
  139. <p><img src="" alt="Parse App: Migration Dialog" /></p>
  140. <p>Click <strong>Begin the migration</strong>. You should see progress dialogs for copying a snapshot of your Parse hosted database to your server, and then for syncing new data since the snapshot was taken. The duration of this process will depend on the amount of data to be transferred, and may be substantial.</p>
  141. <p><img src="" alt="Parse App: Migration Progress" /></p>
  142. <p><img src="" alt="Parse App: Migration Process" /></p>
  143. <h3>Verify Data Migration</h3>
  144. <p>Once finished, the migration process will enter a verification step. Don&rsquo;t finalize the migration yet. You&rsquo;ll first want to make sure the data has actually transferred, and test a local instance of Parse Server.</p>
  145. <p><img src="" alt="Parse App: Finished Migration, Waiting for Finalization" /></p>
  146. <p>From your <code>mongo</code> shell, you can now examine your local database. Begin by using &lt;^>database_name&lt;^> and examining the collections it contains:</p>
  147. <pre><code class="custom_prefix(>)">use <span style="color: red;">database_name</span>
  148. </code></pre>
  149. <pre><code class="custom_prefix(>)">show collections
  150. </code></pre>
  151. <pre><code><span style="color: gray;">Sample Output for Todo App</span><br>
  152. Todo
  153. _Index
  154. _SCHEMA
  155. _Session
  156. _User
  157. _dummy
  158. system.indexes
  159. </code></pre>
  160. <p>You can examine the contents of a specific collection with the <code>.find()</code> method:</p>
  161. <pre><code class="custom_prefix(>)">db.<span style="color: red;">ApplicationName</span>.find()
  162. </code></pre>
  163. <pre><code><span style="color: gray;">Sample Output for Todo App</span><br>
  164. &gt; <span style="color: red;">db.Todo.find()</span>
  165. { "_id" : "hhbrhmBrs0", "order" : NumberLong(1), "_p_user" : "_User$dceklyR50A", "done" : false, "_acl" : { "dceklyR50A" : { "r" : true, "w" : true } }, "_rperm" : [ "dceklyR50A" ], "content" : "Migrate this app to my own server.", "_updated_at" : ISODate("2016-02-08T20:44:26.157Z"), "_wperm" : [ "dceklyR50A" ], "_created_at" : ISODate("2016-02-08T20:44:26.157Z") }
  166. </code></pre>
  167. <p>Your specific output will be different, but you should see data for your app. Once satisfied, exit <code>mongo</code> and return to the shell:</p>
  168. <pre><code class="custom_prefix(>)">exit
  169. </code></pre>
  170. <h2>Step 3 – Install and Configure Parse Server and PM2</h2>
  171. <h3>Create a Dedicated Parse User</h3>
  172. <p>Instead of running <code>parse-server</code> as <strong>root</strong> or your <code>sudo</code> user, we&rsquo;ll create a system user called <strong>parse</strong>:</p>
  173. <pre><code class="command">sudo useradd --create-home --system parse
  174. </code></pre>
  175. <p>Now set a password for <strong>parse</strong>:</p>
  176. <pre><code class="command">sudo passwd parse
  177. </code></pre>
  178. <p>You&rsquo;ll be prompted to enter a password twice.</p>
  179. <h3>Install Parse Server and PM2 Globally</h3>
  180. <p>Use <code>npm</code> to install the <code>parse-server</code> utility, the <code>pm2</code> process manager, and their dependencies, globally:</p>
  181. <pre><code class="command">sudo npm install -g parse-server pm2
  182. </code></pre>
  183. <p><a href="">PM2</a> is a feature-rich process manager, popular with Node.js developers. We&rsquo;ll use the <code>pm2</code> utility to run a simple wrapper script which configures our <code>parse-server</code> instance.</p>
  184. <h3>Retrieve Keys and Write ecosystem.json</h3>
  185. <p>You&rsquo;ll need to retrieve some of the keys for your app. In the Parse dashboard, click on <strong>App Settings</strong> followed by <strong>Security &amp; Keys</strong>:</p>
  186. <p><img src="" alt="Parse Dashboard: App Settings: Security &amp; Keys" /></p>
  187. <p>Of these, only the <strong>Application ID</strong> and <strong>Master Key</strong> are required. Others (client, JavaScript, .NET, and REST API keys) <em>may</em> be necessary to support older client builds, but, if set, will be required in all requests. Unless you have reason to believe otherwise, you should begin by using just the Application ID and Master Key.</p>
  188. <p>With these keys ready to hand, edit a new file called <code>/home/parse/ecosystem.json</code>:</p>
  189. <pre><code class="command">sudo nano /home/parse/ecosystem.json
  190. </code></pre>
  191. <p>Paste the following, changing configuration values to reflect your MongoDB connection string, Application ID, and Master Key:</p>
  192. <pre><code>{
  193. "apps" : [{
  194. "name" : "parse-wrapper",
  195. "script" : "/usr/bin/parse-server",
  196. "watch" : true,
  197. "merge_logs" : true,
  198. "cwd" : "/home/parse",
  199. "env": {
  200. // "PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js",
  201. "PARSE_SERVER_DATABASE_URI": "mongodb://<span style="color: red;">parse</span>:<span style="color: red;">password</span>@<span style="color: red;">your_domain_name</span>:27017/<span style="color: red;">database_name</span>?ssl=true",
  202. "PARSE_SERVER_APPLICATION_ID": "<span style="color: red;">your_application_id</span>",
  203. "PARSE_SERVER_MASTER_KEY": "<span style="color: red;">your_master_key</span>",
  204. }
  205. }]
  206. }
  207. </code></pre>
  208. <p>The <code>env</code> object is used to set environment variables. If you need to configure additional keys, <code>parse-server</code> also recognizes the following variables:</p>
  209. <ul>
  210. <li><code>PARSE_SERVER_COLLECTION_PREFIX</code></li>
  211. <li><code>PARSE_SERVER_CLIENT_KEY</code></li>
  212. <li><code>PARSE_SERVER_REST_API_KEY</code></li>
  213. <li><code>PARSE_SERVER_DOTNET_KEY</code></li>
  214. <li><code>PARSE_SERVER_JAVASCRIPT_KEY</code></li>
  215. <li><code>PARSE_SERVER_DOTNET_KEY</code></li>
  216. <li><code>PARSE_SERVER_FILE_KEY</code></li>
  217. <li><code>PARSE_SERVER_FACEBOOK_APP_IDS</code></li>
  218. </ul>
  219. <p>Exit and save <code>ecosystem.json</code>.</p>
  220. <p>Now, use the <code>su</code> command to become the <strong>parse</strong> user, and run the script with <code>pm2</code>:</p>
  221. <pre><code class="command">sudo su parse
  222. </code></pre>
  223. <pre><code class="custom_prefix(parse\s$)">cd ~
  224. pm2 start ecosystem.json
  225. </code></pre>
  226. <pre><code><span style="color: gray;">Sample Output</span><br>
  227. ...
  228. [PM2] Spawning PM2 daemon
  229. [PM2] PM2 Successfully daemonized
  230. [PM2] Process launched
  231. ┌───────────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────────────┬──────────┐
  232. │ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
  233. ├───────────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────────────┼──────────┤
  234. │ parse-wrapper │ 0 │ fork │ 3499 │ online │ 0 │ 0s │ 13.680 MB │ enabled │
  235. └───────────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────────────┴──────────┘
  236. Use `pm2 show &lt;id|name&gt;` to get more details about an app
  237. </code></pre>
  238. <p>Now tell <code>pm2</code> to save this process list:</p>
  239. <pre><code class="custom_prefix(parse\s$)">pm2 save
  240. </code></pre>
  241. <pre><code><span style="color: gray;">Sample Output</span><br>
  242. [PM2] Dumping processes
  243. </code></pre>
  244. <p>The list of processes <code>pm2</code> is running for the <strong>parse</strong> user should now be stored in <code>/home/parse/.pm2</code>. In order to restore the <code>parse-wrapper</code> we defined in <code>ecosystem.json</code> the next time the server restarts, we will just need to define a startup script to run <code>pm2</code> as <strong>parse</strong> and restore its processes. Fortunately, <code>pm2</code> can generate and install a script on its own.</p>
  245. <p>Exit to your regular <code>sudo</code> user:</p>
  246. <pre><code class="custom_prefix(parse\s$)">exit
  247. </code></pre>
  248. <p>Tell <code>pm2</code> to install initialization scripts, to be run as the <strong>parse</strong> user, using <code>/home/parse</code> as a home directory:</p>
  249. <pre><code class="command">sudo pm2 startup ubuntu -u parse --hp /home/parse/
  250. </code></pre>
  251. <pre><code><strong>Output</strong><br>
  252. [PM2] Spawning PM2 daemon
  253. [PM2] PM2 Successfully daemonized
  254. [PM2] Generating system init script in /etc/init.d/
  255. [PM2] Making script booting at startup...
  256. [PM2] -ubuntu- Using the command:
  257. su -c "chmod +x /etc/init.d/ &amp;&amp; update-rc.d defaults"
  258. System start/stop links for /etc/init.d/ already exist.
  259. [PM2] Done.
  260. </code></pre>
  261. <h2>Step 4 – Install and Configure Nginx</h2>
  262. <p>We&rsquo;ll use the Nginx web server to provide a <strong>reverse proxy</strong> to <code>parse-server</code>, so that we can serve the Parse API securely over TLS/SSL.</p>
  263. <p>Install the <code>nginx</code> package:</p>
  264. <pre><code class="command">sudo apt-get install -y nginx
  265. </code></pre>
  266. <p>Open <code>/etc/nginx/sites-enabled/default</code> in <code>nano</code> (or your editor of choice):</p>
  267. <pre><code class="command">sudo nano /etc/nginx/sites-enabled/default
  268. </code></pre>
  269. <p>Replace its contents with the following:</p>
  270. <pre><code><strong>/etc/nginx/sites-enabled/default</strong><br>
  271. # HTTP - redirect all requests to HTTPS
  272. server {
  273. listen 80;
  274. listen [::]:80 default_server ipv6only=on;
  275. return 301 https://$host$request_uri;
  276. }
  277. # HTTPS - serve HTML from /usr/share/nginx/html, proxy requests to /parse/
  278. # through to Parse Server
  279. server {
  280. listen 443;
  281. server_name <span style="color: red;">your_domain_name</span>;
  282. root /usr/share/nginx/html;
  283. index index.html index.htm;
  284. ssl on;
  285. # Use certificate and key provided by Let's Encrypt:
  286. ssl_certificate /etc/letsencrypt/live/<span style="color: red;">your_domain_name</span>/fullchain.pem;
  287. ssl_certificate_key /etc/letsencrypt/live/<span style="color: red;">your_domain_name</span>/privkey.pem;
  288. ssl_session_timeout 5m;
  289. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  290. ssl_prefer_server_ciphers on;
  291. ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
  292. # Pass requests for /parse/ to Parse Server instance at localhost:1337
  293. location /parse/ {
  294. proxy_set_header X-Real-IP $remote_addr;
  295. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  296. proxy_set_header X-NginX-Proxy true;
  297. proxy_pass http://localhost:1337/;
  298. proxy_ssl_session_reuse off;
  299. proxy_set_header Host $http_host;
  300. proxy_redirect off;
  301. }
  302. location / {
  303. try_files $uri $uri/ =404;
  304. }
  305. }
  306. </code></pre>
  307. <p>Exit the editor and save the file. Restart Nginx so that changes take effect:</p>
  308. <pre><code class="command">sudo service nginx restart
  309. </code></pre>
  310. <pre><code><span style="color: gray;">Output</span><br>
  311. * Restarting nginx nginx
  312. ...done.
  313. </code></pre>
  314. <h2>Step 5 – Test Parse Server</h2>
  315. <p>At this stage, you should have the following:</p>
  316. <ul>
  317. <li>A TLS/SSL certificate, provided by Let&rsquo;s Encrypt</li>
  318. <li>MongoDB, secured with the Let&rsquo;s Encrypt certificate</li>
  319. <li><code>parse-server</code> running under the <strong>parse</strong> user on port 1337, configured with the keys expected by your app</li>
  320. <li><code>pm2</code> managing the <code>parse-server</code> process under the <strong>parse</strong> user, and a startup script to restart <code>pm2</code> on boot</li>
  321. <li><code>nginx</code>, secured with the Let&rsquo;s Encrypt certificate, and configured to proxy connections to <code>https://<span style="color: red;">your_domain_name</span>/parse</code> to the <code>parse-server</code> instance</li>
  322. </ul>
  323. <p>It should be possible to test reads and writes using <code>curl</code>.</p>
  324. <p>&lt;$>[note]
  325. <strong>Note:</strong> The <code>curl</code> commands in this section should be harmless when used with a test or development app. Be cautious when writing data to a production app.
  326. &lt;$></p>
  327. <h3>Writing Data with a POST</h3>
  328. <p>You&rsquo;ll need to give <code>curl</code> several important options:</p>
  329. <table>
  330. <thead>
  331. <tr>
  332. <th> Option </th>
  333. <th> Description </th>
  334. </tr>
  335. </thead>
  336. <tbody>
  337. <tr>
  338. <td> <code>-X POST</code> </td>
  339. <td> Sets the request type, which would otherwise default to <code>GET</code> </td>
  340. </tr>
  341. <tr>
  342. <td> <code>-H "X-Parse-Application-Id: <span style="color: red;">your_application_id</span>"</code> </td>
  343. <td> Sends a header which identifies your application to <code>parse-server</code> </td>
  344. </tr>
  345. <tr>
  346. <td> <code>-H "Content-Type: application/json"</code> </td>
  347. <td> Sends a header which lets <code>parse-server</code> know to expect JSON-formatted data </td>
  348. </tr>
  349. <tr>
  350. <td> <code>-d '{<span style="color: red;">json_data</span>}</code> </td>
  351. <td> Sends the data itself </td>
  352. </tr>
  353. </tbody>
  354. </table>
  355. <p>Putting these all together, we get:</p>
  356. <pre><code>curl -X POST \
  357. -H "X-Parse-Application-Id: <span style="color: red;">your_application_id</span>" \
  358. -H "Content-Type: application/json" \
  359. -d '{"score":1337,"playerName":"Sammy","cheatMode":false}' \
  360. https://<span style="color: red;">your_domain_name</span>/parse/classes/GameScore
  361. </code></pre>
  362. <pre><code><strong>Sample Output</strong><br>
  363. {"objectId":"YpxFdzox3u","createdAt":"2016-02-18T18:03:43.188Z"}
  364. </code></pre>
  365. <h3>Reading Data with a GET</h3>
  366. <p>Since <code>curl</code> sends GET requests by default, and we&rsquo;re not supplying any data, you should only need to send the Application ID in order to read some sample data back:</p>
  367. <pre><code class="command">curl -H "X-Parse-Application-Id: <span style="color: red;">your_application_id</span>"
  368. </code></pre>
  369. <pre><code><strong>Sample Output</strong><br>
  370. {"results":[{"objectId":"BNGLzgF6KB","score":1337,"playerName":"Sammy","cheatMode":false,"updatedAt":"2016-02-17T20:53:59.947Z","createdAt":"2016-02-17T20:53:59.947Z"},{"objectId":"0l1yE3ivB6","score":1337,"playerName":"Sean Plott","cheatMode":false,"updatedAt":"2016-02-18T03:57:00.932Z","createdAt":"2016-02-18T03:57:00.932Z"},{"objectId":"aKgvFqDkXh","score":1337,"playerName":"Sean Plott","cheatMode":false,"updatedAt":"2016-02-18T04:44:01.275Z","createdAt":"2016-02-18T04:44:01.275Z"},{"objectId":"zCKTgKzCRH","score":1337,"playerName":"Sean Plott","cheatMode":false,"updatedAt":"2016-02-18T16:56:51.245Z","createdAt":"2016-02-18T16:56:51.245Z"},{"objectId":"YpxFdzox3u","score":1337,"playerName":"Sean Plott","cheatMode":false,"updatedAt":"2016-02-18T18:03:43.188Z","createdAt":"2016-02-18T18:03:43.188Z"}]}
  371. </code></pre>
  372. <h2>Step 6 – Configure Your App for Parse Server</h2>
  373. <p>tk tk tk</p>
  374. <h2>Step 7 – Finalize Migration</h2>
  375. <p>tk tk tk</p>
  376. <p><img src="" alt="Parse Migration Finalization Dialog" /></p>
  377. <h2>Conclusion and Next Steps</h2>
  378. <p>tk tk tk</p>
  379. </body>
  380. </html>