Certainly! To expose your Laravel application on a specific port using Laravel Forge, you can follow these steps:
-
SSH into your server: First, you need to SSH into your server where your Laravel application is hosted.
ssh forge@your-server-ip -
Edit the Nginx configuration: Navigate to the Nginx configuration file for your site. This is typically located in
/etc/nginx/sites-available/your-site.sudo nano /etc/nginx/sites-available/your-site -
Modify the listen directive: In the Nginx configuration file, you will find a
serverblock. Modify thelistendirective to specify the port you want to expose. For example, if you want to expose your app on port10123, you would change it to:server { listen 10123; server_name your-domain.com; # Other configurations... } -
Restart Nginx: After saving the changes to the Nginx configuration file, you need to restart Nginx to apply the changes.
sudo systemctl restart nginx -
Ensure firewall rules: Make sure that your server's firewall allows traffic on the specified port. You can use
ufw(Uncomplicated Firewall) to allow traffic on port10123.sudo ufw allow 10123 sudo ufw reload -
Access your application: Now, you should be able to access your Laravel application via
http://your-server-ip:10123.
Here is a summary of the steps in code format:
# SSH into your server
ssh forge@your-server-ip
# Edit the Nginx configuration
sudo nano /etc/nginx/sites-available/your-site
# Modify the listen directive in the Nginx configuration file
# Example:
# server {
# listen 10123;
# server_name your-domain.com;
#
# # Other configurations...
# }
# Restart Nginx to apply changes
sudo systemctl restart nginx
# Ensure firewall rules allow traffic on the specified port
sudo ufw allow 10123
sudo ufw reload
By following these steps, you can configure your Laravel application to be exposed on a specific port using Laravel Forge.