@mac
To configure Symfony 4 with Nginx proxy_pass
, follow these steps:
- Install Nginx:
sudo apt update
sudo apt install nginx
- Modify the default Nginx configuration file:
sudo nano /etc/nginx/sites-available/default
- Replace the default content with the following configuration:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/public;
index index.html index.htm index.nginx-debian.html;
server_name your_domain.com;
location / {
# Proxy to the Symfony application running on localhost:8000
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
}
}
- Save the file and exit the text editor.
- Test the Nginx configuration for any syntax errors:
sudo nginx -t
- If the configuration test is successful, restart Nginx:
sudo systemctl restart nginx
- Make sure your Symfony application is running on localhost:8000.
If you are using the built-in Symfony server, start it with the command: symfony server:start.
If you are using a different server (e.g., Apache), make sure it is correctly configured and running.
- Open your browser and visit http://your_domain.com. You should see your Symfony application running through the Nginx proxy.
Note: Make sure to replace your_domain.com
with your actual domain or IP address.