/r/apache

Photograph via snooOG

A subreddit dedicated to the Apache Webserver: here you'll find news, tips and tricks or just ask for assistance, we'll try our best to help each other!

Apache-related news, tips, and tricks.

/r/apache

4,211 Subscribers

2

forwarding non existen URLs to an eternal site

I would like to forward example.com/food to an Adobe Express anchor link. The /food directory currently does not exist on my server.

Can I do this in .htaccess as a rewrite rule so that anywhere I print in marketing materials the URL example.com/food it kicks over to a different website?

I'm trying to avoid paying my URL manager for hosting a custom site.

I tried both of these with no luck

Redirect 301 /food https://new.express.adobe.com/webpage/REGQ0sMUCnX4V#408-innovates-the-food-industry

RewriteRule ^food$ https://new.express.adobe.com/webpage/REGQ0sMUCnX4V#408-innovates-the-food-industry [R=302,L]

8 Comments
2024/10/18
15:25 UTC

1

Config rules, if this matches don't process any further rules

I have a lot of Apache .CONF rules set up, and I'd like to do something in the very beginning that says something like, "if THIS is true, just stop processing all further rules".

I tried this, but /.well-known/acme-challenge/foo still gets a 503 error:

RewriteEngine on

# cPanel fix, exclude DCV checks from future RewriteRules
RewriteCond %{REQUEST_URI} ^/[0-9]+\..+\.cpaneldcv$ [OR]
RewriteCond %{REQUEST_URI} ^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ [OR]

# /.well-known/ is used by AutoSSL
RewriteCond %{REQUEST_URI} ^/\.well-known|[45]\d\d\.(s?html|php)|(ad|robot)s\.txt

RewriteRule ^ - [L]

If this is the proper technique, any idea why it's not matching the third condition?

If it's not the proper technique, what should I use? Maybe [END]?

1 Comment
2024/10/17
17:39 UTC

2

Wordpress and other web app in the same root domain managing their own pages each

Hello, as the title says I am trying to acchieve that, I buy a web app from third party developers but is not great for customization so I want to use wordpress for the main theme, marketing, documentation, funnels, etc... and the webapp to offer a service.

Obviously when I install both in the same directory WordPress gains the controll and the other webapp doesn't work, I know the .htaccess can be modified to tell wordpress to only manage specific pages, the issue is that both (WP & webapp) have the same handler name (index.php) and I can not make it work that way, is there another option???

PD: not looking for subfolders, subdomains or multiple domains.

1 Comment
2024/10/16
18:48 UTC

1

Mod Rewrite with proxy pass

I have a reverse proxy setup that seems to be working well. However, I want to accomplish something that I haven't done before.

I currently have Apache running a reverse proxy to handle SSL, etc. a.domain.com.au is being forwarded to 10.2.3.4:1234/ and is working well. However, the site there (LimeSurvey) is using /index.php/ in the URL, and I want to remove this behavior.

If I set the proxy config to:

ProxyPass / http://10.2.3.4:1234/index.php/

ProxyPassReverse / http://10.2.3.4:1234/index.php/

The behavior works; however, if a link or something beyond that has /index.php in the URI, then the proxy breaks (presumably because it is being redirected to /index.php/index.php/).

How would you go about handling this scenario?

1 Comment
2024/10/15
08:54 UTC

2

You're speaking plain HTTP to an SSL-enabled server port.

Confused by this one. Is there a place I can look and fix this easily?

I just need it to redirect http to https for this one domain, If I understand correctly.

For clarity, this is a domain that is in my vhosts.

I still dont really understand why there is a vhost.conf and a vhosts-le-ssl.conf.

Couldn't they all be in one conf?

Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

4 Comments
2024/10/13
16:17 UTC

2

Mod_rewrite when redirect has ? question mark in query string portion

This is the second vendor we have making this more difficult than they need to be :(

I need to redirect to this (obviously included spaces to break up the URL):

https:/ / 3rdpartyhosteddomain.tld /inventory/?/listings/for-rent/equipment/all?DSCompanyID=999

and I'm getting this which doesn't resolve on their website - all? is becoming all%3f

https:/ / 3rdpartyhosteddomain.tld /inventory/?/listings/for-rent/equipment/all%3fDSCompanyID=999

I've tried escaping with backslash(es) before the question mark (in the .htaccess file). No dice. What's the trick I haven't learned yet and need to add to my arsenal ? Our DNS provider handles it okay if I place the redirect there on their DNS so it must be possible.

3 Comments
2024/10/12
16:41 UTC

1

Everything is fine until I Certbot, now links go to different vhosts

Running a wordpress host on ubuntu, and finally understanding a lot more about apache at a base level.

Im running multi vhosts to a single IP.

Everything seems to be working just fine until I run certbot and get SSL certs. After running it however, it seems to randomly pick one of the domains, and forward all the other domains to that one.

However, when I run certbot, it suddenly makes some domains redirect to a particular domain. Ive tried to figure out why but I am unable to.

I have noticed this message:

After this, domain.ltd, no longer works and forwards instead to anotherdomain.ltd.

Which makes me realize I don't really understand the rewrite piece of the config

Deploying certificate                                                                                                                            
Some rewrite rules copied from /etc/apache2/sites-enabled/httpd-vhosts.conf were disabled in the vhost for your HTTPS site located at /etc/apache
2/sites-available/httpd-vhosts-le-ssl.conf because they have the potential to create redirection loops.                                          
Successfully deployed certificate for domain.ltd to /etc/apache2/sites-available/httpd-vhosts-le-ssl.conf                                 
Congratulations! You have successfully enabled HTTPS on https://domain.ltd 

Here's the config under httpd-vhosts.conf

<VirtualHost *:80>                                                                                                            
        ServerName domain.tld                                                                                                             
        ServerAlias www.domain.tld                                                                                                        
        ServerAdmin admin@domain.tld                                                                                                    
        DocumentRoot /var/www/html/domain.tld                                                                                        
        ErrorLog ${APACHE_LOG_DIR}/error.log                                                                                                     
        CustomLog ${APACHE_LOG_DIR}/access.log combined  
</VirtualHost>

       

I don't fully understand the concept of rewrite either. The behavior seems to exist with or without the below.

RewriteEngine on                                                                                                                                 
RewriteCond %{SERVER_NAME} =domain.tld                                                                          
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]  

Note: I dont fully understand the SSL config piece, and how it relates to the Virtual Host .conf
Certbot seems to make multiple .conf's and im not sure why or how it all relates.

I also dont fully understand the rewrite bit, why is exists nor what it does exactly.

I've been able to have some success to this point by deleting the ssl.conf files.

httpd-vhosts-le-ssl.conf  or there was one httdp-vhosts-le-le-ssl.conf

Any guidance or insight would be greatly apprecaited.  This is driving me nuts.
6 Comments
2024/10/12
00:15 UTC

1

Dashboard for Apache with Geo Location based IP address

Hi all,

Please let me know, if any one using dash board ( Prometheus + Grafana ) for Apache with Geo Location map based IP address.

0 Comments
2024/10/11
17:02 UTC

1

Apache Configuration Error in Dockerized PHP Application

I'm trying to Dockerize my PHP application and learn about Docker in the process, but I'm facing a configuration issue with Apache.

Here’s my docker-compose.yml:

services:
  php:
    image: php:8.1.29-fpm-alpine
    volumes:
      - ./admin:/usr/src/admin
    extra_hosts:
      - "docker-admin.localhost:127.0.0.1"
    expose:
      - "9000"
    entrypoint: ["php-fpm"]

  apache-server:
    build: .
    ports:
      - 8080:80
    volumes:
      - ./admin:/usr/local/apache2/htdocs/admin
    depends_on:
      - php

Here’s my Dockerfile:

FROM httpd:2.4.52-alpine3.15
RUN mkdir -p /usr/local/apache2/conf/vhosts
COPY ./conf/* /usr/local/apache2/conf/vhosts
COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf

And my admin.conf:

<VirtualHost *:80>
ServerName docker-admin.localhost
DocumentRoot /usr/local/apache2/htdocs/apps/admin/public_html
<Directory /usr/local/apache2/htdocs/apps/admin/public_html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

<FilesMatch \.php$>
SetHandler "proxy:fcgi://php:9000"
</FilesMatch>

ErrorLog /usr/local/apache2/error.log
LogLevel warn
CustomLog /usr/local/apache2/access.log combined
</VirtualHost>

Here’s the error I’m getting:

[Sun Oct 06 10:02:48.889047 2024] [authz_core:error] [pid 10:tid 131326541519672] [client 192.168.16.1:49194] AH01630: client denied by server configuration: /usr/local/apache2/htdocs/apps/admin/public_html/.htaccess

Here’s my .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]

I’ve attached the .htaccess

directory permissions reference:

-rw-r--r--    1 504      dialout         45 Jun 11  2007 index.html
drwxrwxr-x   12 www-data www-data      4096 Oct  6 09:57 apps

Can anyone help me understand why I am getting this error?

0 Comments
2024/10/07
05:25 UTC

1

enable htaccess on apache2.4 server

hi i got an apache2.4 webserver that is running but if i enable htaccess files is get on every site only an 505 internal server error but i dont know why because on my old apache2.4 server it worked do any of you have suggestions on how to meke it work?

3 Comments
2024/10/05
22:27 UTC

1

I made a bash script to automate the management of my local php websites.

Initsite is a script that automates the processes I frequently use for both my work and small services at home. I enjoy working with Docker and virtualization environments, I also like to keep things simple.

InitSite - Automated Apache PHP Websites For Your Local Network Development Environment

  • Automated web site deployment/undeployment with ssl, multi-php version, local dns redirection support.
  • Easily add or remove domain aliases.
  • Manage DNS records for internal DNS and local DNS servers.
  • Generate/renew/delete certificates for domain.
  • Get all infos about:
    • Enabled sites on the server.

    • Domain redirections in internal and local dns server records.

    • Installed php versions on the server.

    • Assigned aliases for domains.

Get it here -> InitSite

I’d love to hear your feedback or any suggestions for features you think could enhance the script.

0 Comments
2024/09/30
13:49 UTC

1

Tomcat EOL version with TomEE Plus

I would like to know why Apache TomEE Plus 9.1.3 is shipping EOL Tomcat Version 10.0.27 ?? As per research i have done it shows new vulnerabilities are not tested against 10.0.x branch.

The stable version of TomEE Plus is 9.1.3. TomEE Plus 10.x is a milestone version (if i'm not wrong Milestone stands for under development, please correct me if I'm wrong). The issue is recent vulnerability (CVE-2024-38286) is vulnerable with Tomcat and i can not update Tomcat separately that comes with TomEE Plus.

Can anyone tell me why they are shipping older Tomcat and potential resolution in this scenario. Thanks!!

1 Comment
2024/09/28
11:15 UTC

1

Allow GraphQL?

Newbie here. I'm a longtime desktop app programmer that has been asked to investigate "running GraphQL on our website." I really don't know where to start.🤔

Pretty much all I can tell is we have a hosting service that running Apache 2.4.62. Is there some mod or something that you do to Apache to let it handle GraphQL?

Please forgive my naiveté and if this question is too general. Thanks!

0 Comments
2024/09/27
20:59 UTC

1

Secure Intranet sites issues

I've got a few internal sites that we're looking to sign. I can do this fine with our DMZ external facing servers no problem, but the internal cert has me flummoxed.

Submit an internal form including:

  • Common Name (my.domain.com)
  • Country Name
  • State or Province Name (full name)
  • Locality Name (city)
  • Organization Name(company)
  • Organizational Unit Name (section)
  • Alternate Names - Separated by semi colon (my2.domain.com;my2;my3.domain.com)

Click the Generate button and you get back a Certificate Signing Request along with Private Key. You can then submit that information to the internal helpdesk to have the CSR signed as a .cer file.

On my RHEL 8 server, I add the following to the VirtualHost entry of my httpd.conf file

SSLCertificateFile /etc/pki/tls/certs/vmquery.cer

SSLCertificateKeyFile /etc/pki/tls/certs/RSA_private.key

Restart httpd, and ... not much.

Your connection to this site isn't secure

This site does not have a certificate.

Because this connection is not secure, information (such as passwords or credit cards) will not be securely sent to this site and may be intercepted or seen by others.

Does anybody have some ideas for what I might be missing?

8 Comments
2024/09/24
21:43 UTC

1

How to direct a subdomain to a backing application serving on :8080?

Edit 2:

I had a conflicting conf which I found using:

sudo apachectl -S

And I added a virtual host :443 for the subdomain and it's working.

I'll leave this here if anyone else comes accross this!

Edit:

Turns out this works lol. I guess I just needed to wait for some cacheing to refresh.

Now I just need to figure out how to configure the SSL for the subdomain.

Do I just need to add the "Redirect permanent /" to the subdomain conf?


I have 3 A records:

www.example.com > server IP

example.com > server IP

test.example.com > server IP

Here is the config for example.com:

/etc/apache2/sites-available/example.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName example.com
    ServerAlias www.example.com
    Redirect permanent / https://example.com/
    DocumentRoot /var/www/example
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I have a Golang application serving on :8080 which is running and I can see the HTML when using curl on the server.

Here is the config for test.example.com:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName test.example.com
    ServerAlias www.test.example.com


    ProxyPreserveHost On
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

However, when I apply these and restart apache http://test.example.com just redirects straight to https://example.com.

It works fine If I remove the proxy settings and just point it to a static directory.

What am I doing wrong?

1 Comment
2024/09/24
18:50 UTC

1

How to serve a page without a file extension?

Hello everyone.

Do I do this with option +MultiViews?
If so, where do I put it?

I tried putting it in .htaccess and in 000-default-le-ssl.conf directory section, but it didn't work.
I just get a "page not found"

0 Comments
2024/09/23
00:39 UTC

1

CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

3 Comments
2024/09/21
13:04 UTC

0

Open Office crashes constantly

Every 5-10 minutes Open Office shuts down. I open it again and it restores all the docs I had open but everything since the last time I saved is lost. I tried removing the program and reinstalling it, but it still keeps happening. My wife's does the same thing. Any thoughts? I literally have to click save every 30 seconds because I know it's going to shut down at any moment.

2 Comments
2024/09/19
23:33 UTC

1

Are any of these Cloudflare Optimization features available for Apache (without Cloudflare)?

I'm curious if these are just Apache extensions that Cloudflare is giving a pretty GUI, or if these are proprietary.

HTTP/2
Accelerates your website with HTTP/2

HTTP/2 to Origin
Allow HTTP/2 requests between Cloudflare's edge and your origin

HTTP/3 (with QUIC)
Accelerates HTTP requests by using QUIC, which provides encryption and performance improvements compared to TCP and TLS

Enhanced HTTP/2 Prioritization
Optimizes the order of resource delivery, independent of the browser. Greatest improvements will be experienced by visitors using Safari and Edge browsers

0-RTT Connection Resumption
Improves performance for clients who have previously connected to your website

These are available in Cloudflare's paid Business plan ($250 /month), but they seem to be the only features that have made a real difference and I can't decide if it's worth the money.

1 Comment
2024/09/18
01:57 UTC

2

Bad bots caught in a redirect

I've discovered that bad bots are the cause of a lot of my logged error, trying to get to a nonexistent page like this:

/2004-05.html/1981-82.html/2004-05.html/1967-68.html/WhatEver.html/Games/19721211Whatever.html

They all have several /foo/ subdirectories like that. I think that they attempt to plug one .html on the end of a real script, which shows an error but doesn't 301 redirect (by design, and I really don't want to change that). So then it plugs another page to the end, and so on until it times out after 10 redirects.

No real page on my site will ever have that many slashes in the URI (I honestly think 5 would be the max), so I'm thinking of blocking this in my Apache config using:

RewriteCond %{REQUEST_URI} (?:[^/]+/){9} [NC]
RewriteRule ^ - [F]

Thoughts?

1 Comment
2024/09/15
06:05 UTC

0

Modifying error_log to include account name or domain name

I have a number of these errors in my log:

[Sat Sep 14 14:39:31.603665 2024] [core:error] [pid 10392:tid 10599] [client 123.45.67.89:0] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

I used to have a LOT of these, and found that the issue was from clients that used Wordpress and didn't have a 404.shtml or 403.shtml page; the user (usually a bot) would encounter an error that tried to redirect to a page that didn't exist, then get caught in a loop.

I added these pages to all accounts using Wordpress, and the majority of the errors when away. But I still see them occasionally.

Is there a way to modify the error log so that it includes either the account name or domain name in the log?

I use WHM/cPanel, and I found this in the Apache configuration:

LogFormat (combined)
%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"

LogFormat (common)
%h %l %u %t \"%r\" %>s %b

And I found this in the docs that implies that I can simply add %U somewhere:

https://httpd.apache.org/docs/2.4/mod/mod_log_config.html#formats

But the format in the error_log ([timestamp] [core:error] [pid] [remote_addr] error) doesn't match that format, so I'm not sure that I'm in the right place.

3 Comments
2024/09/14
18:49 UTC

2

"Unsafe URL with %3f", replacing %3f in query string

I'm suddenly seeing a ton of these in my error log, which I understand is a new rule:

Unsafe URL with %3f URL rewritten without UnsafeAllow3F

I changed my site to modify all instances of %3f or %3F to:

// &#63;
%26%2363%3B

This works, but I'm still getting the error in my log. I'm only guessing that bots have cached the %3f and are still querying it?

I tried to change it in Apache config, using:

RewriteEngine on

RewriteCond %{QUERY_STRING} (.+)%3f(.*)
RewriteRule (.+) $1?%1\%26\%2363\%3B%2 [R=301,NC] 

But I can't get it to match. I even tried rewriting to $1?%1-%2 (trying to simplify it), but that didn't match either.

Any suggestions on what I'm doing wrong? Or any better suggestions on how to handle this issue?

2 Comments
2024/09/14
06:39 UTC

2

Next.js and PHP on Same Apache Server: Slow Loading with ProxyPass—How to Optimize?

I have deployed a Next.js application alongside a PHP application on the same Apache server. To route traffic to the Next.js app, I’m using ProxyPass. While everything is working, the Next.js application is loading extremely slowly compared to my local development environment.

My Current Apache Configuration:

<VirtualHost *:80>
    DocumentRoot "/var/www/myapp/dist/"
    ServerName myapp.net
    ServerAlias *.myapp.net

    # Proxy configuration for Next.js
    ProxyRequests Off 
    ProxyPreserveHost On 
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    ProxyTimeout 60
    ProxyBadHeader Ignore
    ProxyIOBufferSize 65536

    # Serve static files directly
    Alias /static /var/www/myapp/static
    <Directory /var/www/myapp/static>
        Require all granted
    </Directory>
    ProxyPass /static !
</VirtualHost>

I'm running nextjs project in dev mode using below command in screen.

npm run dev

Starting...
Ready in 5.7s
Found a change in next.config.mjs. Restarting the server to apply the changes...
Next.js 14.2.5
- Local:        http://localhost:3000
- Environments: .env
Starting...
Ready in 2.5s

Problems:

  1. Slow Loading: The Next.js app is loading significantly slower in production compared to my local environment.
  2. Performance Bottleneck: I’m concerned that ProxyPass might be causing performance issues, but I’m not sure how to improve it.
  3. Gzip Compression: I’ve enabled Gzip compression, but I’m unsure if it’s properly optimized.

Questions:

Is there a better way to configure Apache for serving a Next.js app with ProxyPass?

What other optimizations can I apply to Apache to improve loading times?

Would it make sense to use a different reverse proxy like Nginx in this scenario?

Any advice or suggestions on how to improve the performance of my Next.js application in this setup would be greatly appreciated!

0 Comments
2024/09/13
10:25 UTC

1

Redirect Location to backend api on error status 401 to error component

So I have setup an angular application using Apache. I have created a <Location> directive in the vhost file, in order to proxy to my backend endpoints. Naturally, when making http requests from the angular app, it works to access my backend resources.

My problem is, that I need to access one of my backend enpoints, using my Angular app. Let's say I have the following:

  • myhost: the host were I will access my ui application
  • api/backend/download: the backend api

If I access the download api as: myhost/api/backend/download.

So one of my issues is, if I access that endpoint and It has an error, I receive the json. I want to redirect back into my ui application, to one of my pages, /error.

One of the things I used are as follows:

<Location "/error"> FallbackResource /index.html </Location>

<Location "^/api/backend.*"> ... setup for proxy ProxyErrorOverride On ErrorDocument 401 /error </Location>

Can anyone help me? Thanks in advance

0 Comments
2024/09/12
18:37 UTC

2

What is best configuration for Ubuntu 22 Apache php vps

I want to setup my ubantu 22 vps for my 20 wordpress site. I already installed redis, php fpm, opcacheed still low traffic my vps 100% load. My ram is 16 gb, ram load is ~10%

What is best configaration for my vps

#help

8 Comments
2024/09/09
04:47 UTC

2

What is your favorite custom LogFormat string?

1 Comment
2024/09/05
12:48 UTC

1

Disable CONNECT method

Hello friends, I have an vulnerability with 9449 port on appache tomcant http.conf and I want do disable it for CONNECT method and I have set a buch of lines to deal with it but when I tried the curl command it still didn’t show error 405, can anyone help me with it or give any assistance thankss.

0 Comments
2024/09/05
07:54 UTC

0

Unable to connect trough wss proxy

Hello everyone, I must say right away that there is no way to configure the apache file, so I'm asking for help, when I request it, I get the connection refused error. htaccess :

Options -Multiviews

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP:Upgrade} websocket [NC]

RewriteCond %{HTTP:Connection} upgrade [NC]

RewriteRule /(.*) ws://localhost:9000/$1 [P,L]

ProxyPass / http://localhost:9000/

ProxyPassReverse / http://localhost:9000/

RewriteRule ^check$ http://localhost:9000/check [P,L]

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-s

RewriteRule ^(.*)$ api.php?x=$1 [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^(.*)$ api.php [QSA,NC,L]

RewriteCond %{REQUEST_FILENAME} -s

RewriteRule ^(.*)$ api.php [QSA,NC,L]

</IfModule>

backend code on the localhost to which the redirection occurs :

func 
checkServerHandler
(
w
 
http
.
ResponseWriter
, 
r
 *
http
.
Request
) {
    token := r.URL.
Query
().
Get
("token")
    if token != "1" {
        http.
Error
(w, "Unauthorized", http.StatusUnauthorized)
        return
    }
    conn, err := upgrader.
Upgrade
(w, r, nil)
    if err != nil {
        log.
Println
("Upgrade error:", err)
        http.
Error
(w, "Could not upgrade to websocket", http.StatusInternalServerError)
        return
    }
    defer conn.
Close
()

    mu.
Lock
()
    serverConnections[conn] = 0
    mu.
Unlock
()

    for {
        _, message, err := conn.
ReadMessage
()
        if err != nil {
            log.
Println
("Read error:", err)
            break
        }

        var responseData map[string]interface{}
        err = json.
Unmarshal
(message, &responseData)
        if err != nil {
            log.
Println
("Error unmarshalling response:", err)
            continue
        }

        username, ok := responseData["username"].(string)
        if !ok {
            log.
Println
("Username not found in response")
            continue
        }

        mu.
Lock
()
        responses = 
append
(responses, 
Response
{Username: username, Data: responseData})
        mu.
Unlock
()
    }

    mu.
Lock
()
    
delete
(serverConnections, conn)
    mu.
Unlock
()
}

Code which trying to connect to backend:

def 
listen
(
url
):
    global websocket
    websocket = 
create_connection
(
url
)
    while True:
        try:
            message = websocket.
recv
()
            
print
(
f
"Check request received: {message}")
            executor.
submit
(
handle_message
, message)
        except 
Exception
 as e:
            
print
(
f
"Connection error: {e}, reconnecting...")
            time.
sleep
(5)
            try:
                websocket = 
create_connection
(
url
)
            except 
Exception
 as e:
                
print
(
f
"Failed to reconnect: {e}")
                break


def 
sigterm_handler
(
signum
, 
frame
):
    
print
("SIGTERM received, shutting down gracefully...")
    executor.
shutdown
(
wait
=True)
    if websocket:
        websocket.
close
()
    sys.
exit
(0)


def 
main
():
    url = "wss://somedomen.me/self_report?token=1"
    while True:
        try:
            
listen
(url)
        except 
Exception
 as e:
            
print
(
f
"Error in listen: {e}")
            time.
sleep
(5)

3 Comments
2024/09/02
21:56 UTC

2

The Apache Tomcat Native library which allows using OpenSSL was not found - 404 error

When I imported a working project into another workspace, it throws an error "error the specified resource does not exist".

I import the specified resource (the project) into the new workspace (just like how it was in the workspace where its working) and it's throwing 404 status code without any error in the logs: "Message The requested resource [/clip/] is not available Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists."

Only one piece of information looks different which is "INFO: The Apache Tomcat Native library which allows using OpenSSL was not found on the java.library.path: [C:\Users\pc\Downloads\eclipse\eclipse-jee-2022-09-R-win32-x86_64\eclipse\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin;........................................................many other directories and files location...............................................................C:\Users\pc\AppData\Local\Microsoft\WindowsApps;;C:\Users\pc\Downloads\eclipse\eclipse-jee-2022-09-R-win32-x86_64\eclipse;;.]"

There are also a couple of errors in java code:

  1. The method encodeHexString(byte[]) is undefined for the type Hex
  2. The method encodeBase64String(byte[]) is undefined for the type Base64

But none of the library imports throws any error (so no idea out how these errors pop up for the same code that doesn't throw these errors)

Everything starting from JDK version (1.8), JRE version (8), JAR files, Tomcat server (8.5) is the same. Don't understand how this problem came. Any suggestions?

0 Comments
2024/09/02
07:37 UTC

Back To Top