my frontend runs on nginx and it makes requests to backend, running on spring boot server. Backend and Frontend run on remote linux server. none of my request work, but they used to work locally. Where is the problem?
#failed to fetch
1 messages ยท Page 1 of 1 (latest)
<@&1004656351647117403> please have a look, thanks.
Here is an AI assisted attempt to answer your question ๐ค. Maybe it helps! In any case, a human is on the way ๐. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.
ork before. I have checked the network connection and it seems to be fine. What could be the possible reasons for this issue?
There could be several possible reasons for your requests not working. Here are some common issues to consider:
-
Cross-Origin Resource Sharing (CORS): Check if your backend server has CORS enabled and properly configured to allow requests from your frontend domain. You can do this by inspecting the response headers of your backend API requests.
-
Firewall or Security Groups: Ensure that there are no firewall rules or security groups blocking the communication between your frontend and backend servers. Check if the necessary ports (e.g., 80 for HTTP, 443 for HTTPS) are open for communication.
-
DNS or IP Address Changes: Verify that the DNS records or IP addresses of your frontend and backend servers have not changed unexpectedly. If they have changed, update the configurations accordingly.
-
Server Configuration Changes: Review any recent changes made to the server configurations, such as Nginx or Spring Boot settings, that might affect the communication between frontend and backend.
-
SSL/TLS Certificates: If you are using HTTPS, ensure that your SSL/TLS certificates are valid and properly configured on both frontend and backend servers.
-
Logging and Error Handling: Check the logs of both frontend and backend applications for any error messages or exceptions that might provide insights into what went wrong during the request process.
-
Network Connectivity Issues: Despite checking network connection, there might still be intermittent connectivity issues between your frontend and backend servers due to network problems or infrastructure-related factors.
It is recommended to investigate each of these possibilities systematically to identify the root cause of the issue with your requests not working on your frontend application connected to a remote Spring Boot backend server running on Nginx.
To configure Nginx to make requests to a backend on the same remote server, you can follow these steps:
-
Install Nginx: If you haven't already, install Nginx on your remote server. The installation process may vary depending on your operating system.
-
Configure the backend: Set up your backend application or service that you want Nginx to proxy requests to. Ensure that the backend is running and accessible on a specific port (e.g., localhost:8000).
-
Open the Nginx configuration file: Locate the Nginx configuration file, typically named
nginx.conf, which is usually located in the/etc/nginx/directory. -
Edit the configuration file: Open the
nginx.conffile in a text editor and locate thehttpblock. -
Add a new location block: Inside the
httpblock, add a new location block to define how Nginx should handle requests for your backend. For example:
location /backend {
proxy_pass http://localhost:8000;
}
In this example, any request made to /backend will be forwarded to http://localhost:8000.
-
Save and close the configuration file.
-
Test and reload Nginx: Before applying changes, test the configuration for syntax errors by running
nginx -t. If there are no errors, reload Nginx by runningsudo service nginx reloadorsudo systemctl reload nginx. -
Test the setup: Send a request to your server using the defined location path (e.g.,
http://your-server-ip/backend). Nginx should forward this request to your backend application/service running on port 8000.
Make sure to replace localhost with your actual server IP or hostname if necessary.
Note that these instructions assume a basic setup and may need adjustments based on your specific requirements and environment.
@green stump
Your question has been closed due to inactivity.
If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.
Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.
When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.
Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.
With enough info, someone knows the answer for sure ๐
help me
So these are requests going from your local machine to one of those servers, I would say the nginx one, and failing
Pick the specific request url and investigate why it failed
Is it present in the nginx?
Something is initiating those requests, so your first request probably reached the server, I would guess one to index.html, bu the rest does not
I would first look if those are going to the same address
That is best I can do on such a limited information
i tried, but i get no mesagges
idk, how to check it?
do you mean url?
what else can i provide to give better view of the problem?
hey there!
can you share the headers request from your web browser pls ?
and check your console too
Screenshot of the whole request would be nice, there should be indication of why it happened
I would use tracert on that url, see where it stops
@green stump
Your question has been closed due to inactivity.
If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.
Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.
When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.
Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.
With enough info, someone knows the answer for sure ๐
Hello!
your saying they run on remote , yet your pasting a localhost
Backend and Frontend run on remote linux server
yes
so making call to a localhost is a mistake then?
loaclhost is the same pc
because my logic was: they run on remote machine. so they are locally located
so how should my requst url look like then?
localhost can only connect to itself, if u need another machine u need the IP
get the ip for the remote machine and adjust your url
( and do not ask the adress, its your network ๐ )
Hey there
oh, so now my request to backend will be http://myIP:8080 ?
It's an object inside the DOM
You dnt need to show
Just use it in ur frontend code
Instead of "localhost"
When the app in remote it will take the hostname where it's running
Ohhh, so it wil work locally and on remote servers??
Yes
๐
AND YOU!!!
nice ๐ now remember that localhost adress never leaves the pc itself
๐ค
ok, till my last day
To run a Java application 24/7 on a remote server, you can follow these steps:
-
Choose a remote server: Select a reliable hosting provider or cloud service that offers virtual private servers (VPS) or dedicated servers.
-
Set up the server: Provision the server by installing the necessary operating system (e.g., Linux) and configuring it with required software packages, such as Java Development Kit (JDK), web server (e.g., Apache Tomcat), or application server (e.g., WildFly).
-
Transfer your Java application: Upload your Java application files to the remote server using secure file transfer protocols like SCP or SFTP.
-
Configure firewall and security settings: Ensure that the necessary ports are open in the server's firewall to allow incoming connections to your Java application. Additionally, configure any security measures like SSL certificates if required.
-
Start the Java application: Use SSH to connect to the remote server and navigate to the directory where your Java application is stored. Use command-line tools like
javaorjavacto compile and run your Java application.
-
Run as a background process: To keep your Java application running continuously, you can use tools like
nohuporscreenin Linux to run it as a background process even after you disconnect from SSH. -
Monitor and manage the application: Set up monitoring tools or log aggregators to track your application's performance, logs, and errors remotely. You may also consider using process managers like
systemd,supervisor, or containerization technologies like Docker for better management of your Java application. -
Automate restarts and updates: Create scripts or use tools like cron jobs to automatically restart your Java application in case of crashes or system reboots. Additionally, automate updates by setting up version control systems (e.g., Git) and continuous integration/continuous deployment (CI/CD) pipelines.
-
Ensure high availability: Consider setting up load balancing or clustering techniques to distribute the workload across multiple servers for high availability and fault tolerance.
-
Regular maintenance and backups: Perform regular maintenance tasks like applying security patches, optimizing performance, and taking backups of your Java application and its associated data to prevent data loss.
Remember to consult the documentation of your specific hosting provider or cloud service for any additional steps or recommendations they may have for running Java applications on their platforms.
To use nohup with Java apps on a remote server, you can follow these steps:
-
Connect to the remote server using SSH or any other remote access method.
-
Navigate to the directory where your Java application is located.
-
Run the following command to start your Java application with nohup:
nohup java -jar your_app.jar &Replace
your_app.jarwith the actual name of your Java application JAR file. -
Press Enter to execute the command. The
nohupcommand will detach the process from the current terminal session and prevent it from being terminated when you close the SSH connection. -
You can now safely close the SSH connection without stopping the Java application.
-
To check if your Java application is running, you can use tools like
psorjps. For example:ps aux | grep javaThis command will list all running processes containing "java" in their names.
-
To stop the Java application, you need to find its process ID (PID) using
psorjps, and then use thekillcommand to terminate it. For example:kill <PID>Replace
<PID>with the actual process ID of your Java application.
Note: Make sure that you have appropriate permissions to run commands and access files on the remote server.
GUYS
i was looking at wrong window @north inlet @fiery tree
it did not work, I am dumb + blind
oh it does work, read again
its finding your page, but its requesting a http<S> ๐
so i guess, nginx needs to get reconfigured?
or should i just add "s" after http in my frontend urls?
try the last
cant help on the other solution, maybe gpt has got a solution in its spybase
it did not work
yeah cant help on the other solution, gpt should have something in its spybase that can help
ok, but i still appreciate all your help! Thank you!
