I have the following workflow setup:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Nginx
run: |
sudo apt-get update
sudo apt-get install -y nginx
- name: Update NGINX configuration
run: |
echo "
server {
listen 80;
server_name local.everestate.de;
location / {
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header Host \$http_host;
proxy_pass http://local.everestate.de;
}
}
server {
listen 80;
server_name local.everestate.com;
location / {
proxy_set_header X-Forwarded-For \$remote_addr;
proxy_set_header Host \$http_host;
proxy_pass http://local.everestate.com;
}
}" | sudo tee -a /etc/nginx/sites-available/default > /dev/null
- name: Log NGINX config
run: |
journalctl -xeu nginx.service
cat /etc/nginx/sites-available/default
- name: Start NGINX
run: |
sudo systemctl start nginx
sudo systemctl status nginx.service
sudo journalctl -xeu nginx.service
Adding this part "Update NGINX configuration"(echo ...) ends up with the following error
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details. Error: Process completed with exit code 1.
Locally this config works perfectly, only on github actions I'm having this issue. I was logging the /etc/nginx/sites-available/default file content and it looks like locally. How can I fix it?
Edit: sudo nginx -t gives me this back: nginx: [emerg] host not found in upstream "local.everestate.de" in /etc/nginx/sites-enabled/default:100 nginx: configuration file /etc/nginx/nginx.conf test failed
setting up resolvers and using variables resolved the problem:
run: |
echo "
server {
resolver 127.0.0.11 valid=30s ipv6=off;
listen 80;
server_name local.everestate.de;
location / {
set \$domain http://local.everestate.de;
proxy_pass \$domain;
}
}
server {
resolver 127.0.0.11 valid=30s ipv6=off;
listen 80;
server_name local.everestate.com;
location / {
set \$domain2 http://local.everestate.com;
proxy_pass \$domain2;
}
}"