@dana
To configure Nginx for hosting both an Ember.js frontend application and a WordPress backend, you can use a reverse proxy configuration to route requests to the appropriate server based on the URL path.
Here is an example Nginx configuration file that demonstrates how to achieve this setup:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
server { listen 80; server_name yourdomain.com; location / { proxy_pass http://localhost:4200; // Forward requests to Ember.js application running on port 4200 proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; // Optional: Add additional proxy headers if needed proxy_buffers 16 64k; proxy_buffer_size 128k; } location /blog { proxy_pass http://localhost:8080; // Forward requests to WordPress running on port 8080 proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; // Optional: Add additional proxy headers if needed proxy_buffers 16 64k; proxy_buffer_size 128k; } // Other server configurations go here } |
In this configuration:
Make sure to replace "yourdomain.com" with your actual domain name and update the proxy_pass URLs with the correct ports where your Ember.js and WordPress applications are running.
Once you have updated the Nginx configuration file, restart Nginx to apply the changes:
1
|
sudo systemctl restart nginx |
Your Ember.js frontend application should now be accessible at the root URL, and the WordPress backend should be accessible under the "/blog" path on your domain.